diff --git a/doc/configuration.txt b/doc/configuration.txt index 8d6716223..1f9d92c9b 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 d63483ea1..f36c7b590 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)