From eb346074bb52c6c674a839fe67773c4dd058aa22 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 10 Oct 2023 16:30:52 +0200 Subject: [PATCH] MINOR: h2: Set the BODYLESS_RESP flag on the HTX start-line if necessary When message headers are parsed and an HTX start-line is created, if we detect the response must not have any payload, a specific flag must be set on the HTX start-line. It happens for instance for response to HEAD requests. This flag is useb by the multiplexers to know response payload, if any, must be silently skipped. This was not performed when h2 HEADERS frames were decoded. This HTX flag was specifically added to fix a bug when the splicing is inuse. Thus the H2 multiplexer was not concerned. Because the mux-to-mux fast-forwarding will be introduced, it is important handle this flag in the H2 multiplexer too. --- src/h2.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/h2.c b/src/h2.c index 67a443661..9c60cc6b3 100644 --- a/src/h2.c +++ b/src/h2.c @@ -88,6 +88,7 @@ static struct htx_sl *h2_prepare_htx_reqline(uint32_t fields, struct ist *phdr, struct ist uri, meth_sl; unsigned int flags = HTX_SL_F_NONE; struct htx_sl *sl; + enum http_meth_t meth; size_t i; if ((fields & H2_PHDR_FND_METH) && isteq(phdr[H2_PHDR_IDX_METH], ist("CONNECT"))) { @@ -264,13 +265,17 @@ static struct htx_sl *h2_prepare_htx_reqline(uint32_t fields, struct ist *phdr, flags |= HTX_SL_F_VER_11; // V2 in fact flags |= HTX_SL_F_XFER_LEN; // xfer len always known with H2 + + meth = find_http_meth(meth_sl.ptr, meth_sl.len); + if (meth == HTTP_METH_HEAD) { + *msgf |= H2_MSGF_BODYLESS_RSP; + flags |= HTX_SL_F_BODYLESS_RESP; + } + sl = htx_add_stline(htx, HTX_BLK_REQ_SL, flags, meth_sl, uri, ist("HTTP/2.0")); if (!sl) goto fail; - - sl->info.req.meth = find_http_meth(meth_sl.ptr, meth_sl.len); - if (sl->info.req.meth == HTTP_METH_HEAD) - *msgf |= H2_MSGF_BODYLESS_RSP; + sl->info.req.meth = meth; return sl; fail: return NULL; @@ -559,6 +564,7 @@ static struct htx_sl *h2_prepare_htx_stsline(uint32_t fields, struct ist *phdr, else if (status == 204 || status == 304) { *msgf &= ~H2_MSGF_BODY; *msgf |= H2_MSGF_BODYLESS_RSP; + flags |= HTX_SL_F_BODYLESS_RESP; } /* Set HTX start-line flags */