]> git.kaiwu.me - haproxy.git/commitdiff
REGTESTS: h3: check the options dropping the trailers on the backend side
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 10:26:01 +0000 (11:26 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 12:41:06 +0000 (13:41 +0100)
This reg-test checks "option http-drop-request-trailers" and "option
http-drop-response-trailers" are properly handled by the H3 mux on the
backend side. Since vtest doesn't speak H3, the H2 requests are converted
to H3 and sent over a local qmux connection to a second frontend which
converts them back to H2.

It is related to the commit 2c98edb72 ("BUG/MINOR: h3: use the right
option to drop the trailers on the backend side"). It relies on QMux, so
it may only be backported to 3.5.

reg-tests/http-messaging/h3_drop_trailers.vtc [new file with mode: 0644]

diff --git a/reg-tests/http-messaging/h3_drop_trailers.vtc b/reg-tests/http-messaging/h3_drop_trailers.vtc
new file mode 100644 (file)
index 0000000..4f1a8e9
--- /dev/null
@@ -0,0 +1,139 @@
+# This test checks the options dropping the HTTP trailers are properly
+# handled by the H3 mux on the backend side. Since vtest doesn't speak H3, two
+# HTTP layers are chained inside the same haproxy: the H2 requests emitted by
+# vtest are converted to H3 and sent over a local qmux connection to a second
+# frontend which converts them back to H2 for the vtest server.
+#
+# On the backend side, the request trailers must be dropped when "option
+# http-drop-request-trailers" is set (c1), and must be forwarded otherwise,
+# even if "option http-drop-response-trailers" is set (c2).
+
+varnishtest "H3 options dropping the HTTP trailers on the backend side"
+feature ignore_unknown_macro
+
+# TODO to adjust once QMux compilation is QUIC/SSL free
+feature cmd "$HAPROXY_PROGRAM -cc 'feature(QUIC) && !feature(QUIC_OPENSSL_COMPAT) && !feature(OPENSSL_WOLFSSL) && ssllib_name_startswith(OpenSSL) && openssl_version_atleast(1.1.1)'"
+
+# H2 servers used to check the request trailers forwarded by haproxy. Note that
+# haproxy doesn't ack the server's settings before it has something else to
+# send, hence the absence of a second "rxsettings" below.
+server s1 {
+       rxpri
+       stream 0 {
+               txsettings
+               rxsettings
+               txsettings -ack
+       } -run
+
+       # The trailers are dropped, but the end of the message is received
+       stream 1 {
+               rxreq
+               expect req.url == "/drop"
+               expect req.bodylen == 5
+               expect req.http.x-tlr1 == "<undef>"
+               txresp
+       } -run
+} -start
+
+server s2 {
+       rxpri
+       stream 0 {
+               txsettings
+               rxsettings
+               txsettings -ack
+       } -run
+
+       # The trailers are forwarded
+       stream 1 {
+               rxhdrs
+               expect req.url == "/keep"
+               rxdata
+               expect req.bodylen == 5
+               rxhdrs
+               expect req.http.x-tlr1 == "value1"
+               txresp
+       } -run
+} -start
+
+haproxy h1 -conf {
+    global
+    .if feature(THREAD)
+        thread-groups 1
+    .endif
+       expose-experimental-directives
+       ssl-server-verify none
+
+    defaults
+       mode http
+       timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+       timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
+       timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"
+
+    # second layer: parses the H3 trailers and converts them back to H2. It
+    # must be declared first for its address to be known below.
+    frontend fe_h3
+       bind "fd@${fe_h3}" ssl crt ${testdir}/certs/common.pem alpn h3
+       use_backend be_keep if { path /keep }
+       default_backend be_drop
+
+    backend be_drop
+       server s1 ${s1_addr}:${s1_port} proto h2
+
+    backend be_keep
+       server s2 ${s2_addr}:${s2_port} proto h2
+
+    # first layer: converts the H2 requests to H3, dropping the request
+    # trailers
+    frontend fe_drop
+       bind "fd@${fe_drop}" proto h2
+       default_backend be_h3_drop
+
+    backend be_h3_drop
+       option http-drop-request-trailers
+       server h3 ${h1_fe_h3_addr}:${h1_fe_h3_port} ssl alpn h3
+
+    # first layer: converts the H2 requests to H3, only dropping the response
+    # trailers, so the request trailers must be kept
+    listen fe_keep
+       bind "fd@${fe_keep}" proto h2
+       option http-drop-response-trailers
+       server h3 ${h1_fe_h3_addr}:${h1_fe_h3_port} ssl alpn h3
+} -start
+
+client c1 -connect ${h1_fe_drop_sock} {
+       txpri
+       stream 0 {
+               txsettings
+               rxsettings
+               txsettings -ack
+               rxsettings
+               expect settings.ack == true
+       } -run
+
+       stream 1 {
+               txreq -req POST -scheme http -url /drop -hdr "host" "localhost" -nostrend
+               txdata -data "hello" -nostrend
+               txreq -noadd -hdr "x-tlr1" "value1"
+               rxresp
+               expect resp.status == 200
+       } -run
+} -run
+
+client c2 -connect ${h1_fe_keep_sock} {
+       txpri
+       stream 0 {
+               txsettings
+               rxsettings
+               txsettings -ack
+               rxsettings
+               expect settings.ack == true
+       } -run
+
+       stream 1 {
+               txreq -req POST -scheme http -url /keep -hdr "host" "localhost" -nostrend
+               txdata -data "hello" -nostrend
+               txreq -noadd -hdr "x-tlr1" "value1"
+               rxresp
+               expect resp.status == 200
+       } -run
+} -run