]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: compression: init before deleting headers
authorWilliam Lallemand <wlallemand@exceliance.fr>
Wed, 7 Nov 2012 14:00:23 +0000 (15:00 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Nov 2012 14:23:30 +0000 (15:23 +0100)
Init the compression algorithm before modifying the response headers. So
if the compression init fail, the headers won't be modified.

src/proto_http.c

index 7f2c8061c5b38af80dbe046399b21f95abbe61c4..cd130494c992b1f80f7d0db43326fdb6be2788c4 100644 (file)
@@ -2087,6 +2087,10 @@ int select_compression_response_header(struct session *s, struct buffer *res)
 
        ctx.idx = 0;
 
+       /* initialize compression */
+       if (s->comp_algo->init(&s->comp_ctx, 1) < 0)
+               goto fail;
+
        /* remove Content-Length header */
        if ((msg->flags & HTTP_MSGF_CNT_LEN) && http_find_header2("Content-Length", 14, res->p, &txn->hdr_idx, &ctx))
                http_remove_header2(msg, &txn->hdr_idx, &ctx);
@@ -2110,10 +2114,6 @@ int select_compression_response_header(struct session *s, struct buffer *res)
                http_header_add_tail2(&txn->rsp, &txn->hdr_idx, trash.str, trash.len);
        }
 
-       /* initialize compression */
-       if (s->comp_algo->init(&s->comp_ctx, 1) < 0)
-               goto fail;
-
        return 1;
 
 fail: