aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-10-25 17:32:32 +0000
committercorvid <corvid@lavabit.com>2009-10-25 17:32:32 +0000
commit5e8ba355cb977334f526f7f26d4ba1ee78853510 (patch)
tree2a5d821b5cd39f88bd023c01c4e8564ca2515bdb /src
parent4fca34184fd537cdd414f6b502c8b602e5df8eb4 (diff)
only complain about Content-Length for non-identity Transfer-Encoding
Diffstat (limited to 'src')
-rw-r--r--src/cache.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/cache.c b/src/cache.c
index 12e411f8..d7376439 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -702,16 +702,22 @@ static void Cache_parse_header(CacheEntry_t *entry)
dList_free(warnings);
}
+ /*
+ * Get Transfer-Encoding and initialize decoder
+ */
+ encoding = Cache_parse_field(header, "Transfer-Encoding");
+ entry->TransferDecoder = a_Decode_transfer_init(encoding);
+
+
if ((Length = Cache_parse_field(header, "Content-Length")) != NULL) {
- char *tmp;
- if ((tmp = Cache_parse_field(header, "Transfer-Encoding"))) {
+ if (encoding) {
/*
- * BUG: Should test for _presence_ of headers, not whether they
- * have content.
+ * If Transfer-Encoding is present, Content-Length must be ignored.
+ * If the Transfer-Encoding is non-identity, it is an error.
*/
- MSG_HTTP("Both Content-Length and Transfer-Encoding headers"
- " received.\n");
- dFree(tmp);
+ if (dStrcasecmp(encoding, "identity"))
+ MSG_HTTP("Content-Length and non-identity Transfer-Encoding "
+ "headers both present.\n");
} else {
entry->Flags |= CA_GotLength;
entry->ExpectedSize = MAX(strtol(Length, NULL, 10), 0);
@@ -719,6 +725,8 @@ static void Cache_parse_header(CacheEntry_t *entry)
dFree(Length);
}
+ dFree(encoding); /* free Transfer-Encoding */
+
#ifndef DISABLE_COOKIES
/* BUG: If a server feels like mixing Set-Cookie2 and Set-Cookie
* responses which aren't identical, then we have a problem. I don't
@@ -733,13 +741,6 @@ static void Cache_parse_header(CacheEntry_t *entry)
#endif /* !DISABLE_COOKIES */
/*
- * Get Transfer-Encoding and initialize decoder
- */
- encoding = Cache_parse_field(header, "Transfer-Encoding");
- entry->TransferDecoder = a_Decode_transfer_init(encoding);
- dFree(encoding);
-
- /*
* Get Content-Encoding and initialize decoder
*/
encoding = Cache_parse_field(header, "Content-Encoding");