blob: ebb6328c3014d6de75a75c32c96878529f41b2b3 [file] [log] [blame]
Amaury Denoyellebda34302020-12-11 17:53:11 +01001# This reg-test checks the full support of HTTP protocol upgrade, using a GET
2# method and a Connection: Upgrade header. The equivalent mechanism has been
3# defined in rfc8441 for HTTP/2 using CONNECT and a new pseudo-header
4# :protocol. Check that haproxy handles properly h1/h2 translation of protocol
5# upgrade requests and responses.
6
7varnishtest "h1/h2 support for protocol upgrade test"
8
9feature ignore_unknown_macro
10
Christopher Faulet85a81362020-12-15 17:13:39 +010011#REQUIRE_VERSION=2.4
12
Amaury Denoyellebda34302020-12-11 17:53:11 +010013# http/1.1 server
14server srv_h1 {
15 rxreq
16 expect req.method == "GET"
17 expect req.http.connection == "upgrade"
18 expect req.http.upgrade == "custom_protocol"
19
20 txresp \
21 -status 101 \
22 -hdr "connection: upgrade" \
23 -hdr "upgrade: custom_protocol"
24} -repeat 2 -start
25
26# http2 server
27server srv_h2 {
28 rxpri
29
30 stream 0 {
Amaury Denoyelle0df04362021-10-18 09:43:29 +020031 # manually send RFC8441 SETTINGS_ENABLE_CONNECT_PROTOCOL
32 sendhex "00 00 06 04 00 00 00 00 00 00 08 00 00 00 01"
Amaury Denoyellebda34302020-12-11 17:53:11 +010033 rxsettings
34 txsettings -ack
35 rxsettings
36 expect settings.ack == true
37 } -run
38
39 stream 1 {
40 rxhdrs
41 expect req.method == "CONNECT"
42 expect req.http.:scheme == "https"
43 expect req.http.:path == "/"
44 expect req.http.:authority == "127.0.0.1"
45 expect req.http.:protocol == "custom_protocol"
46
47 txresp \
48 -status 200
49 } -run
50} -repeat 2 -start
51
Amaury Denoyelle0df04362021-10-18 09:43:29 +020052# http2 server without support for RFC8441
53server srv_h2_no_ws {
54 rxpri
55
56 stream 0 {
57 txsettings
58 rxsettings
59 txsettings -ack
60 rxsettings
61 expect settings.ack == true
62 } -run
63
64 stream 1 {
65 rxrst
66 } -run
67} -start
68
69# http2 server without support for RFC8441 : settings announced with value 0
70server srv_h2_no_ws2 {
71 rxpri
72
73 stream 0 {
74 # manually send RFC8441 SETTINGS_ENABLE_CONNECT_PROTOCOL with a value of 0
75 sendhex "00 00 06 04 00 00 00 00 00 00 08 00 00 00 00"
76 txsettings
77 rxsettings
78 txsettings -ack
79 rxsettings
80 expect settings.ack == true
81 } -run
82
83 stream 1 {
84 rxrst
85 } -run
86} -start
87
Amaury Denoyellebda34302020-12-11 17:53:11 +010088haproxy hap -conf {
89 defaults
90 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010091 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
92 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
93 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Amaury Denoyellebda34302020-12-11 17:53:11 +010094
95 # h1 frontend connected to h2 frontend
96 listen frt_h1_h2
97 bind "fd@${frt_h1_h2}"
98 server feh2_srv ${hap_frt_h2_addr}:${hap_frt_h2_port} proto h2
99
100 # h2 frontend connected to srv_h1
101 listen frt_h2
102 bind "fd@${frt_h2}" proto h2
103 server srv_h1 ${srv_h1_addr}:${srv_h1_port}
104
105 # h1 frontend connected to srv_h2
106 listen frt_h1
107 bind "fd@${frt_h1}"
108 server srv_h2 ${srv_h2_addr}:${srv_h2_port} proto h2
109
Amaury Denoyelle0df04362021-10-18 09:43:29 +0200110 # h1 frontend connected to srv_h2_no_ws
111 listen frt_h1_no_ws
112 bind "fd@${frt_h1_no_ws}"
113 server srv_h2_no_ws ${srv_h2_no_ws_addr}:${srv_h2_no_ws_port} proto h2
114
115 # h1 frontend connected to srv_h2_no_ws2
116 listen frt_h1_no_ws2
117 bind "fd@${frt_h1_no_ws2}"
118 server srv_h2_no_ws2 ${srv_h2_no_ws2_addr}:${srv_h2_no_ws2_port} proto h2
119
Amaury Denoyellebda34302020-12-11 17:53:11 +0100120 # h2 frontend connected to h1 frontend
121 listen frt_h2_h1
122 bind "fd@${frt_h2_h1}" proto h2
123 server frt_h1 ${hap_frt_h1_addr}:${hap_frt_h1_port}
124} -start
125
126## connect to h1 translation frontend
127client c1_h1_h2 -connect ${hap_frt_h1_h2_sock} {
128 txreq \
129 -req "GET" \
130 -url "/" \
131 -hdr "host: 127.0.0.1" \
132 -hdr "connection: upgrade" \
133 -hdr "upgrade: custom_protocol"
134
135 rxresp
136 expect resp.status == 101
137 expect resp.http.connection == "upgrade"
138 expect resp.http.upgrade == "custom_protocol"
139} -run
140
141# connect to h2 server frontend
142client c2_h2 -connect ${hap_frt_h2_sock} {
143 txpri
144 stream 0 {
145 txsettings
146 rxsettings
147 txsettings -ack
148 rxsettings
149 expect settings.ack == true
150 } -run
151
152 stream 1 {
153 txreq \
154 -req "CONNECT" \
155 -scheme "http" \
156 -url "/" \
157 -hdr ":authority" "127.0.0.1" \
158 -hdr ":protocol" "custom_protocol"
159
160 rxhdrs
161 expect resp.status == 200
162 } -run
163} -run
164
165# connect to h2 translation frontend
166client c3_h2_h1 -connect ${hap_frt_h2_h1_sock} {
167 txpri
168 stream 0 {
169 txsettings
170 rxsettings
171 txsettings -ack
172 rxsettings
173 expect settings.ack == true
174 } -run
175
176 stream 1 {
177 txreq \
178 -req "CONNECT" \
179 -scheme "http" \
180 -url "/" \
181 -hdr ":authority" "127.0.0.1" \
182 -hdr ":protocol" "custom_protocol"
183
184 rxhdrs
185 expect resp.status == 200
186 } -run
187} -run
188
189# connect to h1 server frontend
190client c4_h1 -connect ${hap_frt_h1_sock} {
191 txreq \
192 -req "GET" \
193 -url "/" \
194 -hdr "host: 127.0.0.1" \
195 -hdr "connection: upgrade" \
196 -hdr "upgrade: custom_protocol"
197
198 rxresp
199 expect resp.status == 101
200 expect resp.http.connection == "upgrade"
201 expect resp.http.upgrade == "custom_protocol"
202} -run
Amaury Denoyelle0df04362021-10-18 09:43:29 +0200203
204# connect via h1 server frontend to h2 server without RFC8441 support
205client c5 -connect ${hap_frt_h1_no_ws_sock} {
206 txreq \
207 -req "GET" \
208 -url "/" \
209 -hdr "host: 127.0.0.1" \
210 -hdr "connection: upgrade" \
211 -hdr "upgrade: custom_protocol"
212
213 rxresp
214 expect resp.status == 502
215} -run
216
217# connect via h1 server frontend to h2 server without RFC8441 support
218client c6 -connect ${hap_frt_h1_no_ws2_sock} {
219 txreq \
220 -req "GET" \
221 -url "/" \
222 -hdr "host: 127.0.0.1" \
223 -hdr "connection: upgrade" \
224 -hdr "upgrade: custom_protocol"
225
226 rxresp
227 expect resp.status == 502
228} -run