From 39e436e222236c4e6c0efe95c304fe89fd01e111 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 15 Apr 2022 15:32:03 +0200 Subject: [PATCH] BUG/MEDIUM: compression: Don't forget to update htx_sl and http_msg flags If the response is compressed, we must update the HTX start-line flags and the HTTP message flags. It is especially important if there is another filter enabled. Otherwise, there is no way to know the C-L header was removed and T-E one was added. Except by looping on headers. This patch is related to the issue #1660. It must backported as far as 2.0 (for HTX part only). --- src/flt_http_comp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 08f684e51..cac7dc04b 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -301,6 +301,7 @@ static int set_compression_response_header(struct comp_state *st, struct stream *s, struct http_msg *msg) { struct htx *htx = htxbuf(&msg->chn->buf); + struct htx_sl *sl; struct http_hdr_ctx ctx; /* @@ -316,17 +317,25 @@ set_compression_response_header(struct comp_state *st, struct stream *s, struct goto error; } + sl = http_get_stline(htx); + if (!sl) + goto error; + /* remove Content-Length header */ if (msg->flags & HTTP_MSGF_CNT_LEN) { ctx.blk = NULL; while (http_find_header(htx, ist("Content-Length"), &ctx, 1)) http_remove_header(htx, &ctx); + msg->flags &= ~HTTP_MSGF_CNT_LEN; + sl->flags &= ~HTX_SL_F_CLEN; } /* add "Transfer-Encoding: chunked" header */ if (!(msg->flags & HTTP_MSGF_TE_CHNK)) { if (!http_add_header(htx, ist("Transfer-Encoding"), ist("chunked"))) goto error; + msg->flags |= HTTP_MSGF_TE_CHNK; + sl->flags |= (HTX_SL_F_XFER_ENC|HTX_SL_F_CHNK); } /* convert "ETag" header to a weak ETag */