From 3131de4767475097eb60bb1641b39e6b647eb289 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sat, 21 Feb 2009 12:27:01 +0100 Subject: [PATCH] Fallback to the raw deflate only when nothing was decompressed so far. It lets view the site from bug 1017. --- src/encoding/deflate.c | 6 ++++-- src/protocol/http/http.c | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/encoding/deflate.c b/src/encoding/deflate.c index aae2e299..2ed742a1 100644 --- a/src/encoding/deflate.c +++ b/src/encoding/deflate.c @@ -124,7 +124,8 @@ deflate_read(struct stream_encoded *stream, unsigned char *buf, int len) } restart: err = inflate(&data->deflate_stream, Z_SYNC_FLUSH); - if (err == Z_DATA_ERROR && !data->after_first_read) { + if (err == Z_DATA_ERROR && !data->after_first_read + && data->deflate_stream.next_out == buf) { /* RFC 2616 requires a zlib header for * "Content-Encoding: deflate", but some HTTP * servers (Microsoft-IIS/6.0 at blogs.msdn.com, @@ -159,7 +160,8 @@ restart: data->last_read = 1; break; } else if (err != Z_OK) { - return -1; + data->last_read = 1; + break; } } while (data->deflate_stream.avail_out > 0); diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c index 650b19f3..98a20da6 100644 --- a/src/protocol/http/http.c +++ b/src/protocol/http/http.c @@ -1057,7 +1057,6 @@ decompress_data(struct connection *conn, unsigned char *data, int len, int *length_of_block; unsigned char *output = NULL; - if (http->length == LEN_CHUNKED) { if (http->chunk_remaining == CHUNK_ZERO_SIZE) state = FINISHING;