From: Christopher Faulet Date: Fri, 29 Jan 2021 10:49:16 +0000 (+0100) Subject: MINOR: mux-h2: Slightly improve request HEADERS frames sending X-Git-Tag: v2.4-dev7~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c29b4bf946ea2aa0b5399ddceaba7a25729a0c45;p=thirdparty%2Fhaproxy.git MINOR: mux-h2: Slightly improve request HEADERS frames sending In h2s_bck_make_req_headers() function, in the loop on the HTX blocks, the most common blocks, the headers, are now handled in first, before the start-line. The same change was already performed on the response HEADERS frames. Thus the code is more consistent now. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 6b7f3e9d60..2de155f311 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -5179,19 +5179,7 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx) if (type == HTX_BLK_EOH) break; - if (type == HTX_BLK_REQ_SL) { - BUG_ON(sl); /* Only one start-line expected */ - sl = htx_get_blk_ptr(htx, blk); - meth = htx_sl_req_meth(sl); - uri = htx_sl_req_uri(sl); - if (sl->info.req.meth == HTTP_METH_HEAD) - h2s->flags |= H2_SF_BODYLESS_RESP; - if (unlikely(uri.len == 0)) { - TRACE_ERROR("no URI in HTX request", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s); - goto fail; - } - } - else if (type == HTX_BLK_HDR) { + if (type == HTX_BLK_HDR) { BUG_ON(!sl); /* The start-line mut be defined before any headers */ if (unlikely(hdr >= sizeof(list)/sizeof(list[0]) - 1)) { TRACE_ERROR("too many headers", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s); @@ -5241,6 +5229,18 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx) hdr++; } + else if (type == HTX_BLK_REQ_SL) { + BUG_ON(sl); /* Only one start-line expected */ + sl = htx_get_blk_ptr(htx, blk); + meth = htx_sl_req_meth(sl); + uri = htx_sl_req_uri(sl); + if (sl->info.req.meth == HTTP_METH_HEAD) + h2s->flags |= H2_SF_BODYLESS_RESP; + if (unlikely(uri.len == 0)) { + TRACE_ERROR("no URI in HTX request", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s); + goto fail; + } + } else { TRACE_ERROR("will not encode unexpected htx block", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s); goto fail;