changeset 12754:d37adb7af391

[gaim-migrate @ 15101] Fix for [ 1397936 ] SIP/SIMPLE generates bad 501 Content-Length may have been wrong if the body is different in a numeric response. committer: Tailor Script <tailor@pidgin.im>
author Thomas Butter <tbutter>
date Sat, 07 Jan 2006 18:50:37 +0000
parents ddae10386677
children 505bc707b641
files src/protocols/simple/simple.c
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/simple/simple.c	Sat Jan 07 18:23:50 2006 +0000
+++ b/src/protocols/simple/simple.c	Sat Jan 07 18:50:37 2006 +0000
@@ -456,20 +456,24 @@
 	GSList *tmp = msg->headers;
 	gchar *name;
 	gchar *value;
-	gchar zero[2] = {'0', '\0'};
 	GString *outstr = g_string_new("");
+	
+	/* When sending the acknowlegements and errors, the content length from the original
+	   message is still here, but there is no body; we need to make sure we're sending the
+	   correct content length */
+	sipmsg_remove_header(msg, "Content-Length");
+	if(body) {
+		gchar len[12];
+		sprintf(len, "%" G_GSIZE_FORMAT , strlen(body));
+		sipmsg_add_header(msg, "Content-Length",len);
+	}
+	else
+		sipmsg_add_header(msg, "Content-Length", "0");
 	g_string_append_printf(outstr, "SIP/2.0 %d %s\r\n", code, text);
 	while(tmp) {
 		name = ((struct siphdrelement*) (tmp->data))->name;
 		value = ((struct siphdrelement*) (tmp->data))->value;
 
-		/* When sending the acknowlegements and errors, the content length from the original
-		   message is still here, but there is no body; we need to make sure we're sending the
-		   correct content length */
-		if(strcmp(name, "Content-Length") == 0 && !body) {
-			value = zero;
-		}
-
 		g_string_append_printf(outstr, "%s: %s\r\n", name, value);
 		tmp = g_slist_next(tmp);
 	}