# HG changeset patch # User Thomas Butter # Date 1136659837 0 # Node ID d37adb7af39173edbd357361c68c1b2a50907c35 # Parent ddae103866771c641d7e32ad282f9730a539df1d [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 diff -r ddae10386677 -r d37adb7af391 src/protocols/simple/simple.c --- 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); }