]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3: set properly HTX EOM/BODYLESS on HEADERS parsing
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 14 Feb 2022 14:49:53 +0000 (15:49 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 15 Feb 2022 16:08:48 +0000 (17:08 +0100)
Adjust the method to detect that a H3 HEADERS frame is the last one of
the stream. If this is true, the flags EOM and BODYLESS must be set on
the HTX message.

src/h3.c

index 987dc053ba683ff7090bd459562d48faf1eb6d5a..6616db6aed0d5dbba5a3c0e01b3164cfff0461db 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -116,6 +116,7 @@ static int h3_decode_qcs(struct qcs *qcs, int fin, void *ctx)
                size_t hlen;
                uint64_t ftype, flen;
                struct buffer b;
+               char last_stream_frame = 0;
 
                /* Work on a copy of <rxbuf> */
                b = h3_b_dup(rxbuf);
@@ -129,6 +130,8 @@ static int h3_decode_qcs(struct qcs *qcs, int fin, void *ctx)
                        break;
 
                b_del(rxbuf, hlen);
+               last_stream_frame = (fin && flen == b_data(rxbuf));
+
                switch (ftype) {
                case H3_FT_DATA:
                        break;
@@ -175,7 +178,10 @@ static int h3_decode_qcs(struct qcs *qcs, int fin, void *ctx)
                        sl = htx_add_stline(htx, HTX_BLK_REQ_SL, flags, meth, path, ist("HTTP/3.0"));
                        if (!sl)
                                goto fail;
-                       sl->flags |= HTX_SL_F_BODYLESS;
+
+                       if (last_stream_frame)
+                               sl->flags |= HTX_SL_F_BODYLESS;
+
                        sl->info.req.meth = find_http_meth(meth.ptr, meth.len);
                        BUG_ON(sl->info.req.meth == HTTP_METH_OTHER);
 
@@ -197,6 +203,9 @@ static int h3_decode_qcs(struct qcs *qcs, int fin, void *ctx)
                        htx_add_endof(htx, HTX_BLK_EOH);
                        htx_to_buf(htx, &htx_buf);
 
+                       if (last_stream_frame)
+                               htx->flags |= HTX_FL_EOM;
+
                        cs = cs_new(qcs->qcc->conn, qcs->qcc->conn->target);
                        cs->ctx = qcs;
                        stream_create_from_cs(cs, &htx_buf);
@@ -220,11 +229,6 @@ static int h3_decode_qcs(struct qcs *qcs, int fin, void *ctx)
                b_del(rxbuf, flen);
        }
 
-       if (htx) {
-               if (fin && !b_data(rxbuf))
-                       htx->flags |= HTX_FL_EOM;
-       }
-
        return 0;
 
  fail: