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.
This commit is contained in:
Christopher Faulet 2021-01-29 11:49:16 +01:00
parent 564981369b
commit c29b4bf946

View File

@ -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;