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