]> git.kaiwu.me - haproxy.git/commitdiff
MEDIUM: mux-h2: Use RAW_DATA blocks to store tunneled data
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 15 Sep 2026 12:00:23 +0000 (14:00 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Sep 2026 15:05:19 +0000 (17:05 +0200)
For a tunneled H2 stream, the end of the HTTP message is reported just after
the headers, when H2_SF_BODY_TUNNEL flag is set. So any DATA frame received
after that carries tunneled data and must be stored in a RAW_DATA block.
h2_frt_transfer_data() was updated accordingly.

Thanks to this change, HTTP data and tunneled data are no longer mixed on
the H2 side. The early end of the message is thus preserved when tunneled
data are received, and the next commit is able to remove the workaround that
was necessary to keep both in separate buffers.

src/mux_h2.c

index 45284923b40d7003040eefe92e92afa11df2c53c..d08cb6eff600615d12abc4d21ce8ed070b74b190 100644 (file)
@@ -6619,7 +6619,14 @@ try_again:
        if (flen > block)
                flen = block;
 
-       sent = htx_add_data(htx, ist2(b_head(&h2c->dbuf), flen));
+       /* Tunneled data must never be mixed with HTTP data. A dedicated block
+        * type is used for them. This way, the end of the HTTP message, reported
+        * just after the headers for a tunneled stream, is preserved.
+        */
+       if (h2s->flags & H2_SF_BODY_TUNNEL)
+               sent = htx_add_raw_data(htx, ist2(b_head(&h2c->dbuf), flen));
+       else
+               sent = htx_add_data(htx, ist2(b_head(&h2c->dbuf), flen));
        TRACE_DATA("move some data to h2s rxbuf", H2_EV_RX_FRAME|H2_EV_RX_DATA, h2c->conn, h2s, 0, (void *)(long)sent);
 
        b_del(&h2c->dbuf, sent);