]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h2: Slightly improve request HEADERS frames sending
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 29 Jan 2021 10:49:16 +0000 (11:49 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 29 Jan 2021 12:28:43 +0000 (13:28 +0100)
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.

src/mux_h2.c

index 6b7f3e9d6039e0d2bda1acfcfb36951d4fc97d7a..2de155f3115c0d76c11f1b98520c1b6c8e6d908b 100644 (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;