From 6fae43511c13b3ff8afbec9a31bc76e67d890a8a Mon Sep 17 00:00:00 2001 From: witekfl Date: Fri, 4 Jan 2013 16:00:50 +0100 Subject: [PATCH] Call decompress_data only for compressed data. Hope this is less missleading than before. --- src/protocol/http/http.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c index f03e9c85..30965311 100644 --- a/src/protocol/http/http.c +++ b/src/protocol/http/http.c @@ -1087,12 +1087,6 @@ decompress_data(struct connection *conn, unsigned char *data, int len, } } - if (conn->content_encoding == ENCODING_NONE) { - *new_len = len; - if (*length_of_block > 0) *length_of_block -= len; - return data; - } - *new_len = 0; /* new_len must be zero if we would ever return NULL */ if (!conn->stream) { @@ -1238,7 +1232,6 @@ read_chunked_http_data(struct connection *conn, struct read_buffer *rb) } } else { - unsigned char *data; int data_len; int zero = (http->chunk_remaining == CHUNK_ZERO_SIZE); int len = zero ? 0 : http->chunk_remaining; @@ -1247,13 +1240,19 @@ read_chunked_http_data(struct connection *conn, struct read_buffer *rb) int_upper_bound(&len, rb->length); conn->received += len; - data = decompress_data(conn, rb->data, len, &data_len); + if (conn->content_encoding == ENCODING_NONE) { + data_len = len; + if (http->chunk_remaining > 0) http->chunk_remaining -= len; + if (add_fragment(conn->cached, conn->from, rb->data, len) == 1) + conn->tries = 0; + } else { + unsigned char *data = decompress_data(conn, rb->data, len, &data_len); - if (add_fragment(conn->cached, conn->from, - data, data_len) == 1) - conn->tries = 0; + if (add_fragment(conn->cached, conn->from, data, data_len) == 1) + conn->tries = 0; - if (data && data != rb->data) mem_free(data); + if (data) mem_free(data); + } conn->from += data_len; total_data_len += data_len; @@ -1298,7 +1297,6 @@ static int read_normal_http_data(struct connection *conn, struct read_buffer *rb) { struct http_connection_info *http = conn->info; - unsigned char *data; int data_len; int len = rb->length; @@ -1309,12 +1307,19 @@ read_normal_http_data(struct connection *conn, struct read_buffer *rb) conn->received += len; - data = decompress_data(conn, rb->data, len, &data_len); + if (conn->content_encoding == ENCODING_NONE) { + data_len = len; + if (http->length > 0) http->length -= len; + if (add_fragment(conn->cached, conn->from, rb->data, data_len) == 1) + conn->tries = 0; + } else { + unsigned char *data = decompress_data(conn, rb->data, len, &data_len); - if (add_fragment(conn->cached, conn->from, data, data_len) == 1) - conn->tries = 0; + if (add_fragment(conn->cached, conn->from, data, data_len) == 1) + conn->tries = 0; - if (data && data != rb->data) mem_free(data); + if (data) mem_free(data); + } conn->from += data_len; -- 2.11.4.GIT