From 2835654f19000ee9b8b689a617936e299b6d6213 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 4 Aug 2009 12:11:03 +0200 Subject: [PATCH] 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 --- libsoup/soup-message-client-io.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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; } -- 2.7.4