From: Christopher Faulet Date: Tue, 17 Oct 2023 09:43:43 +0000 (+0200) Subject: BUG/MINOR: htpp-ana/stats: Specify that HTX redirect messages have a C-L header X-Git-Tag: v2.9-dev8~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0b04920d1;p=thirdparty%2Fhaproxy.git BUG/MINOR: htpp-ana/stats: Specify that HTX redirect messages have a C-L header Redirect responses sent during the HTTP analysis have no payload. However there is still a "Content-Length" header. It is important to set the corresponding flag on the HTX start-line to be sure to preserve this header when the reponse is sent to the client. The same is true with the stats applet, when it returns a redirect responses. It is especially important because we no ignore in-fly modifications of "Content-Length" or "Transfer-Encoding" headers without updating the HTX start-line flags. This patch may be backported to all stable versions but it is probably useless because only the 2.9-dev is affected by the bug. --- diff --git a/src/http_ana.c b/src/http_ana.c index be75eac446..126ffc72ee 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -2417,7 +2417,7 @@ int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struc htx = htx_from_buf(&res->buf); /* Trim any possible response */ channel_htx_truncate(&s->res, htx); - flags = (HTX_SL_F_IS_RESP|HTX_SL_F_VER_11|HTX_SL_F_XFER_LEN|HTX_SL_F_BODYLESS); + flags = (HTX_SL_F_IS_RESP|HTX_SL_F_VER_11|HTX_SL_F_XFER_LEN|HTX_SL_F_CLEN|HTX_SL_F_BODYLESS); sl = htx_add_stline(htx, HTX_BLK_RES_SL, flags, ist("HTTP/1.1"), status, reason); if (!sl) goto fail; @@ -4181,7 +4181,7 @@ void http_perform_server_redirect(struct stream *s, struct stconn *sc) * Create the 302 response */ htx = htx_from_buf(&res->buf); - flags = (HTX_SL_F_IS_RESP|HTX_SL_F_VER_11|HTX_SL_F_XFER_LEN|HTX_SL_F_BODYLESS); + flags = (HTX_SL_F_IS_RESP|HTX_SL_F_VER_11|HTX_SL_F_XFER_LEN|HTX_SL_F_CLEN|HTX_SL_F_BODYLESS); sl = htx_add_stline(htx, HTX_BLK_RES_SL, flags, ist("HTTP/1.1"), ist("302"), ist("Found")); if (!sl) diff --git a/src/stats.c b/src/stats.c index acd3e7e16f..f146d2a601 100644 --- a/src/stats.c +++ b/src/stats.c @@ -4439,7 +4439,7 @@ static int stats_send_http_redirect(struct stconn *sc, struct htx *htx) (ctx->flags & STAT_NO_REFRESH) ? ";norefresh" : "", scope_txt); - flags = (HTX_SL_F_IS_RESP|HTX_SL_F_VER_11|HTX_SL_F_XFER_LEN|HTX_SL_F_CHNK); + flags = (HTX_SL_F_IS_RESP|HTX_SL_F_VER_11|HTX_SL_F_XFER_LEN|HTX_SL_F_CLEN|HTX_SL_F_CHNK); sl = htx_add_stline(htx, HTX_BLK_RES_SL, flags, ist("HTTP/1.1"), ist("303"), ist("See Other")); if (!sl) goto full;