BUG/MINOR: mux-h1: Fix condition to send null-chunk for bodyless message

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.
This commit is contained in:
Christopher Faulet 2026-04-22 16:40:55 +02:00
parent 16485cdebe
commit 392abee6d4

View 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;
}