[libsoup] Mirror Mozilla behavior for when to follow Content-Length
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libsoup] Mirror Mozilla behavior for when to follow Content-Length
- Date: Tue, 4 Aug 2009 19:26:40 +0000 (UTC)
commit 2835654f19000ee9b8b689a617936e299b6d6213
Author: Benjamin Otte <otte gnome org>
Date: Tue Aug 4 12:11:03 2009 +0200
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 files changed, 12 insertions(+), 0 deletions(-)
---
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]