]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: h1: Don't mask websocket protocol if multiple protocols used
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 19 May 2026 09:15:38 +0000 (11:15 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 19 May 2026 15:50:50 +0000 (17:50 +0200)
During H1 message parsing, the Upgrade header values are checked to detect
"websocket" prototol, to properly handle websocket upgrades between H1 and
H2 and to possibly reject messages if mandatory headers are missing.

However, the flag is reset for each new Upgrade header and the information
may be lost. So never reset it.

This patch must be backported as far as 2.4.

reg-tests/http-messaging/websocket.vtc
src/h1.c

index 9567ea577de6478a3665c640f107baa901946fa6..3990ddb9a0efe373c7b7f2e30fcfe8f9ba7a200d 100644 (file)
@@ -146,7 +146,7 @@ client c1 -connect ${hap_fe1_sock} {
 } -run
 
 # missing websocket key
-client c2 -connect ${hap_fe1_sock} {
+client c2_1 -connect ${hap_fe1_sock} {
        txreq \
          -req "GET" \
          -url "/" \
@@ -158,6 +158,19 @@ client c2 -connect ${hap_fe1_sock} {
        expect resp.status == 400
 } -run
 
+client c2_2 -connect ${hap_fe1_sock} {
+       txreq \
+         -req "GET" \
+         -url "/" \
+         -hdr "host: 127.0.0.1" \
+         -hdr "connection: upgrade" \
+         -hdr "upgrade: proto1, websocket, proto2" \
+         -hdr "upgrade: proto3"
+
+       rxresp
+       expect resp.status == 400
+} -run
+
 # missing key on server side
 client c3 -connect ${hap_fe2_sock} {
        txreq \
index 792737c9e3f5ae2bed155545293b71c4ff0ce614..4ea75919135e4595d4afd0aeea5f3be40ade0fa2 100644 (file)
--- a/src/h1.c
+++ b/src/h1.c
@@ -281,8 +281,6 @@ void h1_parse_upgrade_header(struct h1m *h1m, struct ist *value)
        char *e, *n, *p;
        struct ist word;
 
-       h1m->flags &= ~H1_MF_UPG_WEBSOCKET;
-
        word.ptr = value->ptr - 1; // -1 for next loop's pre-increment
        p = value->ptr;
        e = value->ptr + value->len;