Le 06/01/2019 à 16:22, PiBa-NL a écrit :
Hi List,

Using both 1.9.0 and 2.0-dev0-909b9d8 compression happens twice when
configured in defaults.
This was noticed by user walle303 on IRC.

Seems like a bug to me as 1.8.14 does not show this behavior. Attached a
little regtest that reproduces the issue.

Can someone take a look, thanks in advance.


Hi Pieter,

Here is the patch that should fix this issue. Could you confirm please ?

Thanks
--
Christopher Faulet
>From ff3c04e40ab0f4a7176ef25835b40f0d068150cf Mon Sep 17 00:00:00 2001
From: Christopher Faulet <cfau...@haproxy.com>
Date: Mon, 7 Jan 2019 14:41:59 +0100
Subject: [PATCH] BUG/MINOR: compression: Disable it if another one is already
 in progress

Since the commit 9666720c8 ("BUG/MEDIUM: compression: Use the right buffer
pointers to compress input data"), the compression can be done twice. The first
time on the frontend and the second time on the backend. This may happen by
configuring the compression in a default section.

To fix the bug, when the response is checked to know if it should be compressed
or not, if the flag HTTP_MSGF_COMPRESSING is set, the compression is not
performed. It means it is already handled by a previous compression filter.

Thanks to Pieter (PiBa-NL) to report this bug.

This patch must be backported to 1.9.
---
 src/flt_http_comp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c
index 380366b06..f8fbf4c9d 100644
--- a/src/flt_http_comp.c
+++ b/src/flt_http_comp.c
@@ -808,6 +808,10 @@ http_select_comp_reshdr(struct comp_state *st, struct stream *s, struct http_msg
 	if (st->comp_algo == NULL)
 		goto fail;
 
+	/* compression already in progress */
+	if (msg->flags & HTTP_MSGF_COMPRESSING)
+		goto fail;
+
 	/* HTTP < 1.1 should not be compressed */
 	if (!(msg->flags & HTTP_MSGF_VER_11) || !(txn->req.flags & HTTP_MSGF_VER_11))
 		goto fail;
@@ -902,6 +906,10 @@ htx_select_comp_reshdr(struct comp_state *st, struct stream *s, struct http_msg
 	if (st->comp_algo == NULL)
 		goto fail;
 
+	/* compression already in progress */
+	if (msg->flags & HTTP_MSGF_COMPRESSING)
+		goto fail;
+
 	/* HTTP < 1.1 should not be compressed */
 	if (!(msg->flags & HTTP_MSGF_VER_11) || !(txn->req.flags & HTTP_MSGF_VER_11))
 		goto fail;
@@ -1391,7 +1399,6 @@ check_implicit_http_comp_flt(struct proxy *proxy)
 	fconf->conf = NULL;
 	fconf->ops  = &comp_ops;
 	LIST_ADDQ(&proxy->filter_configs, &fconf->list);
-
  end:
 	return err;
 }
-- 
2.20.1

Reply via email to