From: William Lallemand Date: Mon, 26 Nov 2012 13:34:47 +0000 (+0100) Subject: MINOR: compression: disable on multipart or status != 200 X-Git-Tag: v1.5-dev15~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d300261babe838ac3bdd2f5e2353980845fb3929;p=thirdparty%2Fhaproxy.git MINOR: compression: disable on multipart or status != 200 The compression is disabled when the HTTP status code is not 200, indeed compression on some HTTP code can create issues (ex: 206, 416). Multipart message should not be compressed eitherway. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 8d6716223b..1f9d92c9b1 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -1916,7 +1916,9 @@ compression offload Compression is disabled when: * the server is not HTTP/1.1. + * HTTP status code is not 200 * requests does not contain Transfer-Encoding: chunked or Content-Length. + * Content-Type is multipart * the request contains "Cache-control: no-transform". * User-Agent matches "Mozilla/4" except MSIE 6 with XP SP2, or MSIE 7 and later. * The response is already compressed (see compression offload). diff --git a/src/proto_http.c b/src/proto_http.c index d63483ea1f..f36c7b590e 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -2060,6 +2060,10 @@ int select_compression_response_header(struct session *s, struct buffer *res) if (!(msg->flags & HTTP_MSGF_VER_11)) goto fail; + /* 200 only */ + if (txn->status != 200) + goto fail; + ctx.idx = 0; /* Content-Length is null */ @@ -2093,6 +2097,13 @@ int select_compression_response_header(struct session *s, struct buffer *res) ctx.idx = 0; + /* Don't compress multipart */ + if (http_find_header2("Content-Type", 12, res->p, &txn->hdr_idx, &ctx)) { + if (strncasecmp("multipart", ctx.line+ctx.val, 9) == 0) + goto fail; + + } + /* limit compression rate */ if (global.comp_rate_lim > 0) if (read_freq_ctr(&global.comp_bps_in) > global.comp_rate_lim)