blob: ec7a7c123163b0c1966578bbd5f457a5888c7b8f [file] [log] [blame]
Christopher Faulet8f161482018-12-19 11:49:39 +01001varnishtest "HTTP request tests: H2 to H1 (HTX and legacy mode)"
Willy Tarreau7b8d2032018-12-13 19:35:29 +01002#REQUIRE_VERSION=1.9
3
4# Run it with HAPROXY_PROGRAM=$PWD/haproxy varnishtest -l -k -t 1 "$1"
5
6feature ignore_unknown_macro
7
8# synchronize requests between streams
9barrier b1 cond 2 -cyclic
10barrier b2 cond 2 -cyclic
11barrier b3 cond 2 -cyclic
12barrier b4 cond 2 -cyclic
Willy Tarreauba9afd22023-08-09 08:32:48 +020013barrier b5 cond 2 -cyclic
14barrier b6 cond 2 -cyclic
Willy Tarreau7b8d2032018-12-13 19:35:29 +010015
16server s1 {
17 rxreq
18 txresp \
19 -status 200 \
20 -body "response 1"
21
22 barrier b2 sync
23 rxreq
24 txresp \
25 -status 200 \
26 -body "response 2"
27
28 barrier b3 sync
29 rxreq
30 txresp \
31 -status 200 \
32 -body "response 3"
33
34 barrier b4 sync
Willy Tarreau1915ca22019-01-24 11:49:37 +010035 # the next request is never received
Willy Tarreauba9afd22023-08-09 08:32:48 +020036
37 barrier b5 sync
38 # the next request is never received
39
40 barrier b6 sync
41 # the next request is never received
Willy Tarreau7b8d2032018-12-13 19:35:29 +010042} -repeat 2 -start
43
44haproxy h1 -conf {
Willy Tarreaue1465c12021-05-09 14:41:41 +020045 global
46 # WT: limit false-positives causing "HTTP header incomplete" due to
47 # idle server connections being randomly used and randomly expiring
48 # under us.
49 tune.idle-pool.shared off
50
Willy Tarreau7b8d2032018-12-13 19:35:29 +010051 defaults
52 #log stdout format raw daemon
53 mode http
Willy Tarreau4a7b5b32018-12-14 09:51:48 +010054 option http-buffer-request
Christopher Faulet8f161482018-12-19 11:49:39 +010055 ${no-htx} option http-use-htx
Willy Tarreau7b8d2032018-12-13 19:35:29 +010056 timeout connect 1s
57 timeout client 1s
58 timeout server 1s
59
60 listen feh1
61 bind "fd@${feh1}"
62 bind "fd@${feh2}" proto h2
63 server s1 ${s1_addr}:${s1_port}
64} -start
65
66client c1h2 -connect ${h1_feh2_sock} {
67 txpri
68 stream 0 {
69 txsettings
70 rxsettings
71 txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +010072 rxsettings
73 expect settings.ack == true
74 } -run
75
76 # first request is valid
77 stream 1 {
78 txreq \
79 -req "GET" \
80 -scheme "https" \
81 -url "/test1.html"
82 rxhdrs
83 expect resp.status == 200
84 rxdata -all
85 expect resp.body == "response 1"
86 } -run
87
88 # second request is valid and advertises C-L:0
89 stream 3 {
90 barrier b2 sync
91 txreq \
92 -req "GET" \
93 -scheme "https" \
94 -url "/test2.html" \
95 -hdr "content-length" "0"
96 rxhdrs
97 expect resp.status == 200
98 rxdata -all
99 expect resp.body == "response 2"
100 } -run
101
102 # third request sends a body with a GET
103 stream 5 {
104 barrier b3 sync
105 txreq \
106 -req "GET" \
107 -scheme "https" \
108 -url "/test3.html" \
109 -nostrend \
110 -body "this must be delivered, like it or not"
111 rxwinup
112 rxhdrs
113 expect resp.status == 200
114 rxdata -all
115 expect resp.body == "response 3"
116 } -run
117
Willy Tarreau1915ca22019-01-24 11:49:37 +0100118 # fourth request is valid and advertises C-L:2, and close, and is
119 # followed by a string "this is not sent\r\n\r\n" which causes a
120 # stream error of type PROTOCOL_ERROR.
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100121 stream 7 {
122 barrier b4 sync
123 txreq \
124 -req "GET" \
125 -scheme "https" \
126 -url "/test4.html" \
Willy Tarreau1915ca22019-01-24 11:49:37 +0100127 -hdr "content-length" "2" \
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100128 -nostrend
129 txdata -data "this is sent and ignored"
Willy Tarreau1915ca22019-01-24 11:49:37 +0100130 rxrst
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100131 } -run
Willy Tarreauba9afd22023-08-09 08:32:48 +0200132
133 # fifth request is invalid and advertises an invalid C-L ending with an
134 # empty value, which results in a stream error.
135 stream 9 {
136 barrier b5 sync
137 txreq \
138 -req "GET" \
139 -scheme "https" \
140 -url "/test5.html" \
141 -hdr "content-length" "0," \
142 -nostrend
143 rxrst
144 } -run
145
146 # sixth request is invalid and advertises an empty C-L, which results
147 # in a stream error.
148 stream 11 {
149 barrier b6 sync
150 txreq \
151 -req "GET" \
152 -scheme "https" \
153 -url "/test6.html" \
154 -hdr "content-length" "" \
155 -nostrend
156 rxrst
157 } -run
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100158} -run
159
160# HEAD requests : don't work well yet
161#client c2h2 -connect ${h1_feh2_sock} {
162# txpri
163# stream 0 {
164# txsettings
165# rxsettings
166# txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100167# rxsettings
168# expect settings.ack == true
169# } -run
170#
171# # first request is valid
172# stream 1 {
173# txreq \
174# -req "HEAD" \
175# -scheme "https" \
176# -url "/test11.html"
177# rxhdrs
178# expect resp.status == 200
179# rxdata -all
180# expect resp.bodylen == 0
181# } -run
182#
183# # second request is valid and advertises C-L:0
184# stream 3 {
185# barrier b2 sync
186# txreq \
187# -req "HEAD" \
188# -scheme "https" \
189# -url "/test12.html" \
190# -hdr "content-length" "0"
191# rxhdrs
192# expect resp.status == 200
193# rxdata -all
194# expect resp.bodylen == 0
195# } -run
196#
197# # third request sends a body with a GET
198# stream 5 {
199# barrier b3 sync
200# txreq \
201# -req "HEAD" \
202# -scheme "https" \
203# -url "/test13.html" \
204# -nostrend \
205# -body "this must be delivered, like it or not"
206# rxwinup
207# rxhdrs
208# expect resp.status == 200
209# rxdata -all
210# expect resp.bodylen == 0
211# } -run
212#
213# # fourth request is valid and advertises C-L:0, and close, and is
214# # followed by a string "this is not sent\r\n\r\n" which must be
215# # dropped.
216# stream 7 {
217# barrier b4 sync
218# txreq \
219# -req "HEAD" \
220# -scheme "https" \
221# -url "/test14.html" \
222# -hdr "content-length" "0" \
223# -nostrend
224# txdata -data "this is sent and ignored"
225# rxwinup
226# rxhdrs
227# expect resp.status == 200
228# rxdata -all
229# expect resp.bodylen == 0
230# } -run
231#} -run
232
233# POST requests
234client c3h2 -connect ${h1_feh2_sock} {
235 txpri
236 stream 0 {
237 txsettings
238 rxsettings
239 txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100240 rxsettings
241 expect settings.ack == true
242 } -run
243
244 # first request is valid
245 stream 1 {
246 txreq \
247 -req "POST" \
248 -scheme "https" \
249 -url "/test21.html"
250 rxhdrs
251 expect resp.status == 200
252 rxdata -all
253 expect resp.body == "response 1"
254 } -run
255
256 # second request is valid and advertises C-L:0
257 stream 3 {
258 barrier b2 sync
259 txreq \
260 -req "POST" \
261 -scheme "https" \
262 -url "/test22.html" \
263 -hdr "content-length" "0"
264 rxhdrs
265 expect resp.status == 200
266 rxdata -all
267 expect resp.body == "response 2"
268 } -run
269
270 # third request sends a body with a GET
271 stream 5 {
272 barrier b3 sync
273 txreq \
274 -req "POST" \
275 -scheme "https" \
276 -url "/test23.html" \
277 -nostrend \
278 -body "this must be delivered, like it or not"
279 rxwinup
280 rxhdrs
281 expect resp.status == 200
282 rxdata -all
283 expect resp.body == "response 3"
284 } -run
285
Willy Tarreau1915ca22019-01-24 11:49:37 +0100286 # fourth request is valid and advertises C-L:2, and close, and is
287 # followed by a string "this is not sent\r\n\r\n" which results
288 # in a stream error.
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100289 stream 7 {
290 barrier b4 sync
291 txreq \
292 -req "POST" \
293 -scheme "https" \
294 -url "/test24.html" \
Willy Tarreau1915ca22019-01-24 11:49:37 +0100295 -hdr "content-length" "2" \
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100296 -nostrend
297 txdata -data "this is sent and ignored"
Willy Tarreau1915ca22019-01-24 11:49:37 +0100298 rxrst
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100299 } -run
Willy Tarreauba9afd22023-08-09 08:32:48 +0200300
301 # fifth request is invalid and advertises invalid C-L ending with an
302 # empty value, which results in a stream error.
303 stream 9 {
304 barrier b5 sync
305 txreq \
306 -req "POST" \
307 -scheme "https" \
308 -url "/test25.html" \
309 -hdr "content-length" "0," \
310 -nostrend
311 rxrst
312 } -run
313
314 # sixth request is invalid and advertises an empty C-L, which results
315 # in a stream error.
316 stream 11 {
317 barrier b6 sync
318 txreq \
319 -req "POST" \
320 -scheme "https" \
321 -url "/test26.html" \
322 -hdr "content-length" "" \
323 -nostrend
324 rxrst
325 } -run
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100326} -run