blob: 6fc536aed5f35291c434019727b434e254cf0a23 [file] [log] [blame]
Willy Tarreau7b8d2032018-12-13 19:35:29 +01001varnishtest "HTTP request tests: H2 to H1, legacy mode"
2#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
13
14server s1 {
15 rxreq
16 txresp \
17 -status 200 \
18 -body "response 1"
19
20 barrier b2 sync
21 rxreq
22 txresp \
23 -status 200 \
24 -body "response 2"
25
26 barrier b3 sync
27 rxreq
28 txresp \
29 -status 200 \
30 -body "response 3"
31
32 barrier b4 sync
33 rxreq
34 txresp \
35 -status 200 \
36 -body "response 4"
37} -repeat 2 -start
38
39haproxy h1 -conf {
40 defaults
41 #log stdout format raw daemon
42 mode http
Willy Tarreau4a7b5b32018-12-14 09:51:48 +010043 option http-buffer-request
Willy Tarreau7b8d2032018-12-13 19:35:29 +010044 #option http-use-htx
45 timeout connect 1s
46 timeout client 1s
47 timeout server 1s
48
49 listen feh1
50 bind "fd@${feh1}"
51 bind "fd@${feh2}" proto h2
52 server s1 ${s1_addr}:${s1_port}
53} -start
54
55client c1h2 -connect ${h1_feh2_sock} {
56 txpri
57 stream 0 {
58 txsettings
59 rxsettings
60 txsettings -ack
61 rxwinup
62 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
108 # fourth request is valid and advertises C-L:0, and close, and is
109 # followed by a string "this is not sent\r\n\r\n" which must be
110 # dropped.
111 stream 7 {
112 barrier b4 sync
113 txreq \
114 -req "GET" \
115 -scheme "https" \
116 -url "/test4.html" \
117 -hdr "content-length" "0" \
118 -nostrend
119 txdata -data "this is sent and ignored"
120 rxwinup
121 rxhdrs
122 expect resp.status == 200
123 rxdata -all
124 expect resp.body == "response 4"
125 } -run
126} -run
127
128# HEAD requests : don't work well yet
129#client c2h2 -connect ${h1_feh2_sock} {
130# txpri
131# stream 0 {
132# txsettings
133# rxsettings
134# txsettings -ack
135# rxwinup
136# rxsettings
137# expect settings.ack == true
138# } -run
139#
140# # first request is valid
141# stream 1 {
142# txreq \
143# -req "HEAD" \
144# -scheme "https" \
145# -url "/test11.html"
146# rxhdrs
147# expect resp.status == 200
148# rxdata -all
149# expect resp.bodylen == 0
150# } -run
151#
152# # second request is valid and advertises C-L:0
153# stream 3 {
154# barrier b2 sync
155# txreq \
156# -req "HEAD" \
157# -scheme "https" \
158# -url "/test12.html" \
159# -hdr "content-length" "0"
160# rxhdrs
161# expect resp.status == 200
162# rxdata -all
163# expect resp.bodylen == 0
164# } -run
165#
166# # third request sends a body with a GET
167# stream 5 {
168# barrier b3 sync
169# txreq \
170# -req "HEAD" \
171# -scheme "https" \
172# -url "/test13.html" \
173# -nostrend \
174# -body "this must be delivered, like it or not"
175# rxwinup
176# rxhdrs
177# expect resp.status == 200
178# rxdata -all
179# expect resp.bodylen == 0
180# } -run
181#
182# # fourth request is valid and advertises C-L:0, and close, and is
183# # followed by a string "this is not sent\r\n\r\n" which must be
184# # dropped.
185# stream 7 {
186# barrier b4 sync
187# txreq \
188# -req "HEAD" \
189# -scheme "https" \
190# -url "/test14.html" \
191# -hdr "content-length" "0" \
192# -nostrend
193# txdata -data "this is sent and ignored"
194# rxwinup
195# rxhdrs
196# expect resp.status == 200
197# rxdata -all
198# expect resp.bodylen == 0
199# } -run
200#} -run
201
202# POST requests
203client c3h2 -connect ${h1_feh2_sock} {
204 txpri
205 stream 0 {
206 txsettings
207 rxsettings
208 txsettings -ack
209 rxwinup
210 rxsettings
211 expect settings.ack == true
212 } -run
213
214 # first request is valid
215 stream 1 {
216 txreq \
217 -req "POST" \
218 -scheme "https" \
219 -url "/test21.html"
220 rxhdrs
221 expect resp.status == 200
222 rxdata -all
223 expect resp.body == "response 1"
224 } -run
225
226 # second request is valid and advertises C-L:0
227 stream 3 {
228 barrier b2 sync
229 txreq \
230 -req "POST" \
231 -scheme "https" \
232 -url "/test22.html" \
233 -hdr "content-length" "0"
234 rxhdrs
235 expect resp.status == 200
236 rxdata -all
237 expect resp.body == "response 2"
238 } -run
239
240 # third request sends a body with a GET
241 stream 5 {
242 barrier b3 sync
243 txreq \
244 -req "POST" \
245 -scheme "https" \
246 -url "/test23.html" \
247 -nostrend \
248 -body "this must be delivered, like it or not"
249 rxwinup
250 rxhdrs
251 expect resp.status == 200
252 rxdata -all
253 expect resp.body == "response 3"
254 } -run
255
256 # fourth request is valid and advertises C-L:0, and close, and is
257 # followed by a string "this is not sent\r\n\r\n" which must be
258 # dropped.
259 stream 7 {
260 barrier b4 sync
261 txreq \
262 -req "POST" \
263 -scheme "https" \
264 -url "/test24.html" \
265 -hdr "content-length" "0" \
266 -nostrend
267 txdata -data "this is sent and ignored"
268 rxwinup
269 rxhdrs
270 expect resp.status == 200
271 rxdata -all
272 expect resp.body == "response 4"
273 } -run
274} -run