From: Christopher Faulet Date: Tue, 12 Dec 2023 12:56:05 +0000 (+0100) Subject: BUG/MEDIUM: mux-h1: Explicitly skip request's C-L header if not set originally X-Git-Tag: v3.0-dev1~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=966a18e2b485901bd986ebe65670dc4bfbfe65b5;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: mux-h1: Explicitly skip request's C-L header if not set originally Commit f89ba27caa ("BUG/MEDIUM: mux-h1; Ignore headers modifications about payload representation") introduced a regression. The Content-Length is no longer sent to the server for requests without payload but with a 'Content-Lnegth' header explicitly set to 0, like POST request with no payload. It is of course unexpected. In some cases, depending on the server, such requests are considered as invalid and a 411-Length-Required is returned. The above commit is not directly responsible for the bug, it only reveals a too lax condition to skip the 'Content-Length' header of bodyless requests. We must only skip this header if none was originally found, during the parsing. This patch should fix the issue #2386. It must be backported to 2.9. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index cb70b84b4b..8adfeac15b 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -2046,7 +2046,7 @@ static size_t h1_make_reqline(struct h1s *h1s, struct h1m *h1m, struct htx *htx, if (sl->flags & HTX_SL_F_XFER_ENC) h1m->flags |= H1_MF_XFER_ENC; - if (sl->flags & HTX_SL_F_BODYLESS) { + if (sl->flags & HTX_SL_F_BODYLESS && !(h1m->flags & H1_MF_CLEN)) { h1m->flags = (h1m->flags & ~H1_MF_CHNK) | H1_MF_CLEN; h1s->flags |= H1S_F_HAVE_CLEN; }