From: Benjamin Otte Date: Tue, 4 Aug 2009 10:11:03 +0000 (+0200) Subject: Mirror Mozilla behavior for when to follow Content-Length X-Git-Tag: LIBSOUP_2_27_90~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2835654f19000ee9b8b689a617936e299b6d6213;p=platform%2Fupstream%2Flibsoup.git Mirror Mozilla behavior for when to follow Content-Length Mozilla only honors content length on messages that use keep-alive to work around servers that send broken Content-Length headers. This patch mirrors that behavior. An example for such a page is http://sourceforge.net/apps/wordpress/sourceforge --- diff --git a/libsoup/soup-message-client-io.c b/libsoup/soup-message-client-io.c index 8159922..654b320 100644 --- a/libsoup/soup-message-client-io.c +++ b/libsoup/soup-message-client-io.c @@ -56,6 +56,18 @@ parse_response_headers (SoupMessage *req, if (*encoding == SOUP_ENCODING_UNRECOGNIZED) return SOUP_STATUS_MALFORMED; + /* mirror Mozilla here: + * (see netwerk/protocol/http/src/nsHttpTransaction.cpp for details) + * + * HTTP servers have been known to send erroneous Content-Length headers. + * So, unless the connection is persistent, we must make allowances for a + * possibly invalid Content-Length header. Thus, if NOT persistent, we + * simply accept the whole message. + */ + if (*encoding == SOUP_ENCODING_CONTENT_LENGTH && + !soup_message_is_keepalive (req)) + *encoding = SOUP_ENCODING_EOF; + return SOUP_STATUS_OK; }