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).
diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c
index 08f684e..cac7dc0 100644
--- a/src/flt_http_comp.c
+++ b/src/flt_http_comp.c
@@ -301,6 +301,7 @@
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 @@
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 */