blob: 91d1056d86d550a26c01c710f4cd084b4d53d5c3 [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
3# Run it with HAPROXY_PROGRAM=$PWD/haproxy varnishtest -l -k -t 1 "$1"
4
5feature ignore_unknown_macro
6
7# synchronize requests between streams
8barrier b1 cond 2 -cyclic
9barrier b2 cond 2 -cyclic
10barrier b3 cond 2 -cyclic
11barrier b4 cond 2 -cyclic
12
13server s1 {
14 rxreq
15 txresp \
16 -status 200 \
17 -body "response 1"
18
19 barrier b2 sync
20 rxreq
21 txresp \
22 -status 200 \
23 -body "response 2"
24
25 barrier b3 sync
26 rxreq
27 txresp \
28 -status 200 \
29 -body "response 3"
30
31 barrier b4 sync
Willy Tarreau1915ca22019-01-24 11:49:37 +010032 # the next request is never received
Willy Tarreau7b8d2032018-12-13 19:35:29 +010033} -repeat 2 -start
34
35haproxy h1 -conf {
Willy Tarreaue1465c12021-05-09 14:41:41 +020036 global
37 # WT: limit false-positives causing "HTTP header incomplete" due to
38 # idle server connections being randomly used and randomly expiring
39 # under us.
40 tune.idle-pool.shared off
41
Willy Tarreau7b8d2032018-12-13 19:35:29 +010042 defaults
43 #log stdout format raw daemon
44 mode http
Willy Tarreau4a7b5b32018-12-14 09:51:48 +010045 option http-buffer-request
Willy Tarreauf6739232021-11-18 17:46:22 +010046 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
47 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
48 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Willy Tarreau7b8d2032018-12-13 19:35:29 +010049
50 listen feh1
51 bind "fd@${feh1}"
52 bind "fd@${feh2}" proto h2
53 server s1 ${s1_addr}:${s1_port}
54} -start
55
56client c1h2 -connect ${h1_feh2_sock} {
57 txpri
58 stream 0 {
59 txsettings
60 rxsettings
61 txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +010062 rxsettings
63 expect settings.ack == true
64 } -run
65
66 # first request is valid
67 stream 1 {
68 txreq \
69 -req "GET" \
70 -scheme "https" \
71 -url "/test1.html"
72 rxhdrs
73 expect resp.status == 200
74 rxdata -all
75 expect resp.body == "response 1"
76 } -run
77
78 # second request is valid and advertises C-L:0
79 stream 3 {
80 barrier b2 sync
81 txreq \
82 -req "GET" \
83 -scheme "https" \
84 -url "/test2.html" \
85 -hdr "content-length" "0"
86 rxhdrs
87 expect resp.status == 200
88 rxdata -all
89 expect resp.body == "response 2"
90 } -run
91
92 # third request sends a body with a GET
93 stream 5 {
94 barrier b3 sync
95 txreq \
96 -req "GET" \
97 -scheme "https" \
98 -url "/test3.html" \
99 -nostrend \
100 -body "this must be delivered, like it or not"
101 rxwinup
102 rxhdrs
103 expect resp.status == 200
104 rxdata -all
105 expect resp.body == "response 3"
106 } -run
107
Willy Tarreau1915ca22019-01-24 11:49:37 +0100108 # fourth request is valid and advertises C-L:2, and close, and is
109 # followed by a string "this is not sent\r\n\r\n" which causes a
110 # stream error of type PROTOCOL_ERROR.
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100111 stream 7 {
112 barrier b4 sync
113 txreq \
114 -req "GET" \
115 -scheme "https" \
116 -url "/test4.html" \
Willy Tarreau1915ca22019-01-24 11:49:37 +0100117 -hdr "content-length" "2" \
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100118 -nostrend
119 txdata -data "this is sent and ignored"
Willy Tarreau1915ca22019-01-24 11:49:37 +0100120 rxrst
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100121 } -run
122} -run
123
124# HEAD requests : don't work well yet
125#client c2h2 -connect ${h1_feh2_sock} {
126# txpri
127# stream 0 {
128# txsettings
129# rxsettings
130# txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100131# rxsettings
132# expect settings.ack == true
133# } -run
134#
135# # first request is valid
136# stream 1 {
137# txreq \
138# -req "HEAD" \
139# -scheme "https" \
140# -url "/test11.html"
141# rxhdrs
142# expect resp.status == 200
143# rxdata -all
144# expect resp.bodylen == 0
145# } -run
146#
147# # second request is valid and advertises C-L:0
148# stream 3 {
149# barrier b2 sync
150# txreq \
151# -req "HEAD" \
152# -scheme "https" \
153# -url "/test12.html" \
154# -hdr "content-length" "0"
155# rxhdrs
156# expect resp.status == 200
157# rxdata -all
158# expect resp.bodylen == 0
159# } -run
160#
161# # third request sends a body with a GET
162# stream 5 {
163# barrier b3 sync
164# txreq \
165# -req "HEAD" \
166# -scheme "https" \
167# -url "/test13.html" \
168# -nostrend \
169# -body "this must be delivered, like it or not"
170# rxwinup
171# rxhdrs
172# expect resp.status == 200
173# rxdata -all
174# expect resp.bodylen == 0
175# } -run
176#
177# # fourth request is valid and advertises C-L:0, and close, and is
178# # followed by a string "this is not sent\r\n\r\n" which must be
179# # dropped.
180# stream 7 {
181# barrier b4 sync
182# txreq \
183# -req "HEAD" \
184# -scheme "https" \
185# -url "/test14.html" \
186# -hdr "content-length" "0" \
187# -nostrend
188# txdata -data "this is sent and ignored"
189# rxwinup
190# rxhdrs
191# expect resp.status == 200
192# rxdata -all
193# expect resp.bodylen == 0
194# } -run
195#} -run
196
197# POST requests
198client c3h2 -connect ${h1_feh2_sock} {
199 txpri
200 stream 0 {
201 txsettings
202 rxsettings
203 txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100204 rxsettings
205 expect settings.ack == true
206 } -run
207
208 # first request is valid
209 stream 1 {
210 txreq \
211 -req "POST" \
212 -scheme "https" \
213 -url "/test21.html"
214 rxhdrs
215 expect resp.status == 200
216 rxdata -all
217 expect resp.body == "response 1"
218 } -run
219
220 # second request is valid and advertises C-L:0
221 stream 3 {
222 barrier b2 sync
223 txreq \
224 -req "POST" \
225 -scheme "https" \
226 -url "/test22.html" \
227 -hdr "content-length" "0"
228 rxhdrs
229 expect resp.status == 200
230 rxdata -all
231 expect resp.body == "response 2"
232 } -run
233
234 # third request sends a body with a GET
235 stream 5 {
236 barrier b3 sync
237 txreq \
238 -req "POST" \
239 -scheme "https" \
240 -url "/test23.html" \
241 -nostrend \
242 -body "this must be delivered, like it or not"
243 rxwinup
244 rxhdrs
245 expect resp.status == 200
246 rxdata -all
247 expect resp.body == "response 3"
248 } -run
249
Willy Tarreau1915ca22019-01-24 11:49:37 +0100250 # fourth request is valid and advertises C-L:2, and close, and is
251 # followed by a string "this is not sent\r\n\r\n" which results
252 # in a stream error.
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100253 stream 7 {
254 barrier b4 sync
255 txreq \
256 -req "POST" \
257 -scheme "https" \
258 -url "/test24.html" \
Willy Tarreau1915ca22019-01-24 11:49:37 +0100259 -hdr "content-length" "2" \
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100260 -nostrend
261 txdata -data "this is sent and ignored"
Willy Tarreau1915ca22019-01-24 11:49:37 +0100262 rxrst
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100263 } -run
264} -run