/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *  Author : Richard GAYRAUD - 04 Nov 2003
 *           Olivier Jacques
 *           From Hewlett Packard Company.
 *           Shriram Natarajan
 *           Peter Higginson
 *           Eric Miller
 *           Venkatesh
 *           Enrico Hartung
 *           Nasir Khan
 *           Lee Ballard
 *           Guillaume Teissier from FTR&D
 *           Wolfgang Beck
 *           Venkatesh
 *           Vlad Troyanker
 *           Charles P Wright from IBM Research
 *           Amit On from Followap
 *           Jan Andres from Freenet
 *           Ben Evans from Open Cloud
 *           Marc Van Diest from Belgacom
 */
Index: sipp.2007-04-21/call.cpp
===================================================================
--- sipp.2007-04-21.orig/call.cpp
+++ sipp.2007-04-21/call.cpp
@@ -1172,7 +1172,19 @@ char * call::get_header(char* message, c
       if(ptr) { *ptr = 0; }
       // Add "," when several headers are present
       if (dest != last_header) {
+	/* Remove trailing whitespaces, tabs, and CRs */
+	while ((dest > last_header) &&
+	    ((*(dest - 1) == ' ') || (*(dest - 1) == '\r')|| (*(dest - 1)== '\t'))) {
+	  *(dest--) = 0;
+	}
+
 	dest += sprintf(dest, ",");
+
+	/* We only want to append the contents of the header, not its name for
+	 * the second value. */
+	if (!content) {
+	  src += strlen(name);
+	}
       }
       dest += sprintf(dest, "%s", src);
       if(ptr) { *ptr = '\n'; }
