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).
This commit is contained in:
parent
32af9a7830
commit
39e436e222
@ -301,6 +301,7 @@ static int
|
|||||||
set_compression_response_header(struct comp_state *st, struct stream *s, struct http_msg *msg)
|
set_compression_response_header(struct comp_state *st, struct stream *s, struct http_msg *msg)
|
||||||
{
|
{
|
||||||
struct htx *htx = htxbuf(&msg->chn->buf);
|
struct htx *htx = htxbuf(&msg->chn->buf);
|
||||||
|
struct htx_sl *sl;
|
||||||
struct http_hdr_ctx ctx;
|
struct http_hdr_ctx ctx;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -316,17 +317,25 @@ set_compression_response_header(struct comp_state *st, struct stream *s, struct
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sl = http_get_stline(htx);
|
||||||
|
if (!sl)
|
||||||
|
goto error;
|
||||||
|
|
||||||
/* remove Content-Length header */
|
/* remove Content-Length header */
|
||||||
if (msg->flags & HTTP_MSGF_CNT_LEN) {
|
if (msg->flags & HTTP_MSGF_CNT_LEN) {
|
||||||
ctx.blk = NULL;
|
ctx.blk = NULL;
|
||||||
while (http_find_header(htx, ist("Content-Length"), &ctx, 1))
|
while (http_find_header(htx, ist("Content-Length"), &ctx, 1))
|
||||||
http_remove_header(htx, &ctx);
|
http_remove_header(htx, &ctx);
|
||||||
|
msg->flags &= ~HTTP_MSGF_CNT_LEN;
|
||||||
|
sl->flags &= ~HTX_SL_F_CLEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add "Transfer-Encoding: chunked" header */
|
/* add "Transfer-Encoding: chunked" header */
|
||||||
if (!(msg->flags & HTTP_MSGF_TE_CHNK)) {
|
if (!(msg->flags & HTTP_MSGF_TE_CHNK)) {
|
||||||
if (!http_add_header(htx, ist("Transfer-Encoding"), ist("chunked")))
|
if (!http_add_header(htx, ist("Transfer-Encoding"), ist("chunked")))
|
||||||
goto error;
|
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 */
|
/* convert "ETag" header to a weak ETag */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user