]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: compression: disable on multipart or status != 200
authorWilliam Lallemand <wlallemand@exceliance.fr>
Mon, 26 Nov 2012 13:34:47 +0000 (14:34 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2012 15:02:58 +0000 (16:02 +0100)
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.

doc/configuration.txt
src/proto_http.c

index 8d6716223b6f7a8d5e615c465b3dd98505889c04..1f9d92c9b1dd9cb3192baa24561ae73cdcdd545d 100644 (file)
@@ -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).
index d63483ea1f679900a2cf05af2e22282b5a3f3753..f36c7b590e4d8c5d5603de5588fa4b04c4550811 100644 (file)
@@ -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)