]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: htpp-ana/stats: Specify that HTX redirect messages have a C-L header
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 17 Oct 2023 09:43:43 +0000 (11:43 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 17 Oct 2023 16:11:04 +0000 (18:11 +0200)
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.

src/http_ana.c
src/stats.c

index be75eac446602e944abb3cc4ebfa23949fa1d175..126ffc72eeeaf4ad68eee2f531fc4da411d661c7 100644 (file)
@@ -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)
index acd3e7e16f962a4d369604b65724b598d1ea797d..f146d2a6018eb938a5bf0c987bd2b3ade243d56d 100644 (file)
@@ -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;