]> git.kaiwu.me - haproxy.git/commitdiff
REGTESTS: http-messaging: check that 1xx don't abort H2 backend tunnels
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 17 Nov 2026 15:37:38 +0000 (16:37 +0100)
committerOlivier Houchard <cognet@ci0.org>
Tue, 17 Nov 2026 15:29:59 +0000 (16:29 +0100)
This test sends a CONNECT request, then an Extended CONNECT request (via
an H1 upgrade), through H2 backends whose servers answer with an interim
response then with a 200 response, and checks that data may then be
exchanged in the tunnel. It validates the previous fix.

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

diff --git a/reg-tests/http-messaging/h2_connect_1xx.vtc b/reg-tests/http-messaging/h2_connect_1xx.vtc
new file mode 100644 (file)
index 0000000..ac4e0fc
--- /dev/null
@@ -0,0 +1,92 @@
+# This test checks that an interim response (1xx) received from an H2 server
+# for a CONNECT or an Extended CONNECT request does not abort the tunnel
+# attempt: the final 200 response must still establish the tunnel and data
+# must be exchanged.
+
+varnishtest "H2 backend: interim response before the 200 of a CONNECT tunnel"
+feature ignore_unknown_macro
+
+server s1 {
+    rxpri
+    stream 0 {
+        txsettings
+        rxsettings
+        txsettings -ack
+    } -run
+    stream 1 {
+        rxhdrs
+        expect req.method == "CONNECT"
+        txresp -status 103 -nostrend
+        txresp -status 200 -nostrend
+        rxwinup
+        rxdata
+        expect frame.data == "ping"
+        txdata -data "pong"
+    } -run
+} -start
+
+# H2 server supporting RFC8441 (SETTINGS_ENABLE_CONNECT_PROTOCOL)
+server s2 {
+    rxpri
+    stream 0 {
+        sendhex "00 00 06 04   00    00 00 00 00    00 08   00 00 00 01"
+        rxsettings
+        txsettings -ack
+        rxsettings
+        expect settings.ack == true
+    } -run
+    stream 1 {
+        rxhdrs
+        expect req.method == "CONNECT"
+        expect req.http.:protocol == "custom_protocol"
+        txresp -status 100 -nostrend
+        txresp -status 200 -nostrend
+        rxwinup
+        rxdata
+        expect frame.data == "ping"
+        txdata -data "pong"
+    } -run
+} -start
+
+haproxy h1 -conf {
+    defaults
+        mode http
+        timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+        timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
+        timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"
+
+    frontend fe
+        bind "fd@${fe}"
+        default_backend be
+
+    backend be
+        server s1 ${s1_addr}:${s1_port} proto h2
+
+    frontend fe_ext
+        bind "fd@${fe_ext}"
+        default_backend be_ext
+
+    backend be_ext
+        server s2 ${s2_addr}:${s2_port} proto h2
+} -start
+
+client c1 -connect ${h1_fe_sock} {
+    txreq -method CONNECT -url "example.com:443" -hdr "host: example.com:443"
+    rxresp
+    expect resp.status == 103
+    rxresphdrs
+    expect resp.status == 200
+    send "ping"
+    recv 4
+} -run
+
+client c2 -connect ${h1_fe_ext_sock} {
+    txreq -url "/" -hdr "host: 127.0.0.1" -hdr "connection: upgrade" -hdr "upgrade: custom_protocol"
+    rxresphdrs
+    expect resp.status == 100
+    rxresphdrs
+    expect resp.status == 101
+    expect resp.http.upgrade == "custom_protocol"
+    send "ping"
+    recv 4
+} -run