blob: eaa024a92dff80eef155cff6bcfd42c951023312 [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 Denoyelle68993a12021-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 Denoyelle68993a12021-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
91 ${no-htx} option http-use-htx
92 timeout connect 1s
93 timeout client 1s
94 timeout server 1s
95
96 # h1 frontend connected to h2 frontend
97 listen frt_h1_h2
98 bind "fd@${frt_h1_h2}"
99 server feh2_srv ${hap_frt_h2_addr}:${hap_frt_h2_port} proto h2
100
101 # h2 frontend connected to srv_h1
102 listen frt_h2
103 bind "fd@${frt_h2}" proto h2
104 server srv_h1 ${srv_h1_addr}:${srv_h1_port}
105
106 # h1 frontend connected to srv_h2
107 listen frt_h1
108 bind "fd@${frt_h1}"
109 server srv_h2 ${srv_h2_addr}:${srv_h2_port} proto h2
110
Amaury Denoyelle68993a12021-10-18 09:43:29 +0200111 # h1 frontend connected to srv_h2_no_ws
112 listen frt_h1_no_ws
113 bind "fd@${frt_h1_no_ws}"
114 server srv_h2_no_ws ${srv_h2_no_ws_addr}:${srv_h2_no_ws_port} proto h2
115
116 # h1 frontend connected to srv_h2_no_ws2
117 listen frt_h1_no_ws2
118 bind "fd@${frt_h1_no_ws2}"
119 server srv_h2_no_ws2 ${srv_h2_no_ws2_addr}:${srv_h2_no_ws2_port} proto h2
120
Amaury Denoyellebda34302020-12-11 17:53:11 +0100121 # h2 frontend connected to h1 frontend
122 listen frt_h2_h1
123 bind "fd@${frt_h2_h1}" proto h2
124 server frt_h1 ${hap_frt_h1_addr}:${hap_frt_h1_port}
125} -start
126
127## connect to h1 translation frontend
128client c1_h1_h2 -connect ${hap_frt_h1_h2_sock} {
129 txreq \
130 -req "GET" \
131 -url "/" \
132 -hdr "host: 127.0.0.1" \
133 -hdr "connection: upgrade" \
134 -hdr "upgrade: custom_protocol"
135
136 rxresp
137 expect resp.status == 101
138 expect resp.http.connection == "upgrade"
139 expect resp.http.upgrade == "custom_protocol"
140} -run
141
142# connect to h2 server frontend
143client c2_h2 -connect ${hap_frt_h2_sock} {
144 txpri
145 stream 0 {
146 txsettings
147 rxsettings
148 txsettings -ack
149 rxsettings
150 expect settings.ack == true
151 } -run
152
153 stream 1 {
154 txreq \
155 -req "CONNECT" \
156 -scheme "http" \
157 -url "/" \
158 -hdr ":authority" "127.0.0.1" \
159 -hdr ":protocol" "custom_protocol"
160
161 rxhdrs
162 expect resp.status == 200
163 } -run
164} -run
165
166# connect to h2 translation frontend
167client c3_h2_h1 -connect ${hap_frt_h2_h1_sock} {
168 txpri
169 stream 0 {
170 txsettings
171 rxsettings
172 txsettings -ack
173 rxsettings
174 expect settings.ack == true
175 } -run
176
177 stream 1 {
178 txreq \
179 -req "CONNECT" \
180 -scheme "http" \
181 -url "/" \
182 -hdr ":authority" "127.0.0.1" \
183 -hdr ":protocol" "custom_protocol"
184
185 rxhdrs
186 expect resp.status == 200
187 } -run
188} -run
189
190# connect to h1 server frontend
191client c4_h1 -connect ${hap_frt_h1_sock} {
192 txreq \
193 -req "GET" \
194 -url "/" \
195 -hdr "host: 127.0.0.1" \
196 -hdr "connection: upgrade" \
197 -hdr "upgrade: custom_protocol"
198
199 rxresp
200 expect resp.status == 101
201 expect resp.http.connection == "upgrade"
202 expect resp.http.upgrade == "custom_protocol"
203} -run
Amaury Denoyelle68993a12021-10-18 09:43:29 +0200204
205# connect via h1 server frontend to h2 server without RFC8441 support
206client c5 -connect ${hap_frt_h1_no_ws_sock} {
207 txreq \
208 -req "GET" \
209 -url "/" \
210 -hdr "host: 127.0.0.1" \
211 -hdr "connection: upgrade" \
212 -hdr "upgrade: custom_protocol"
213
214 rxresp
215 expect resp.status == 502
216} -run
217
218# connect via h1 server frontend to h2 server without RFC8441 support
219client c6 -connect ${hap_frt_h1_no_ws2_sock} {
220 txreq \
221 -req "GET" \
222 -url "/" \
223 -hdr "host: 127.0.0.1" \
224 -hdr "connection: upgrade" \
225 -hdr "upgrade: custom_protocol"
226
227 rxresp
228 expect resp.status == 502
229} -run