]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Fix condition to send null-chunk for bodyless message
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 22 Apr 2026 14:40:55 +0000 (16:40 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 23 Apr 2026 08:21:53 +0000 (10:21 +0200)
When the EOH block is processed, before sending message headers, there is a
test to know if there is no payload. In case of a chunked message, a
null-chunk is emitted, except for bodyless response. For instance, a
response to a HEAD request has no payload at all and no null-chunk.

However, the test for bodyless responses is not correct. Only
H1S_F_BODYLESS_RESP flag is tested. But this flag can be set on server side
when we are processing the request. To fix the issue, the test was
adapted. The null-chunk is added if a message with no payload is chunked and
it is a request or a non-bodyless responses.

This patch must be backported to all stable version.

src/mux_h1.c

index eaf9f43c87fa63dcf1f3775afc652c11cb94c8be..b05ddcc9acb9f076ef793caa6c69503ff106b37a 100644 (file)
@@ -2988,7 +2988,8 @@ static size_t h1_make_eoh(struct h1s *h1s, struct h1m *h1m, struct htx *htx, siz
                 * payload. If cannot be removed now. We must emit the end of
                 * the message first to be sure the output buffer is not full
                 */
-               if ((h1m->flags & H1_MF_CHNK) && !(h1s->flags & H1S_F_BODYLESS_RESP)) {
+               if ((h1m->flags & H1_MF_CHNK) && (!(h1m->flags & H1_MF_RESP) || !(h1s->flags & H1S_F_BODYLESS_RESP))) {
+                       /* Send null-chunk except for bodyless reasponses */
                        if (!chunk_memcat(&outbuf, "\r\n0\r\n\r\n", 7))
                                goto full;
                }