blob: acb56b0091e4ca774e834453e10ddfcf43bdc2a2 [file] [log] [blame]
Willy Tarreau7b8d2032018-12-13 19:35:29 +01001varnishtest "HTTP request tests: H2 to H1, HTX 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
43 option http-use-htx
44 timeout connect 1s
45 timeout client 1s
46 timeout server 1s
47
48 listen feh1
49 bind "fd@${feh1}"
50 bind "fd@${feh2}" proto h2
51 server s1 ${s1_addr}:${s1_port}
52} -start
53
54client c1h2 -connect ${h1_feh2_sock} {
55 txpri
56 stream 0 {
57 txsettings
58 rxsettings
59 txsettings -ack
60 rxwinup
61 rxsettings
62 expect settings.ack == true
63 } -run
64
65 # first request is valid
66 stream 1 {
67 txreq \
68 -req "GET" \
69 -scheme "https" \
70 -url "/test1.html"
71 rxhdrs
72 expect resp.status == 200
73 rxdata -all
74 expect resp.body == "response 1"
75 } -run
76
77 # second request is valid and advertises C-L:0
78 stream 3 {
79 barrier b2 sync
80 txreq \
81 -req "GET" \
82 -scheme "https" \
83 -url "/test2.html" \
84 -hdr "content-length" "0"
85 rxhdrs
86 expect resp.status == 200
87 rxdata -all
88 expect resp.body == "response 2"
89 } -run
90
91 # third request sends a body with a GET
92 stream 5 {
93 barrier b3 sync
94 txreq \
95 -req "GET" \
96 -scheme "https" \
97 -url "/test3.html" \
98 -nostrend \
99 -body "this must be delivered, like it or not"
100 rxwinup
101 rxhdrs
102 expect resp.status == 200
103 rxdata -all
104 expect resp.body == "response 3"
105 } -run
106
107 # fourth request is valid and advertises C-L:0, and close, and is
108 # followed by a string "this is not sent\r\n\r\n" which must be
109 # dropped.
110 stream 7 {
111 barrier b4 sync
112 txreq \
113 -req "GET" \
114 -scheme "https" \
115 -url "/test4.html" \
116 -hdr "content-length" "0" \
117 -nostrend
118 txdata -data "this is sent and ignored"
119 rxwinup
120 rxhdrs
121 expect resp.status == 200
122 rxdata -all
123 expect resp.body == "response 4"
124 } -run
125} -run
126
127# HEAD requests : don't work well yet
128#client c2h2 -connect ${h1_feh2_sock} {
129# txpri
130# stream 0 {
131# txsettings
132# rxsettings
133# txsettings -ack
134# rxwinup
135# rxsettings
136# expect settings.ack == true
137# } -run
138#
139# # first request is valid
140# stream 1 {
141# txreq \
142# -req "HEAD" \
143# -scheme "https" \
144# -url "/test11.html"
145# rxhdrs
146# expect resp.status == 200
147# rxdata -all
148# expect resp.bodylen == 0
149# } -run
150#
151# # second request is valid and advertises C-L:0
152# stream 3 {
153# barrier b2 sync
154# txreq \
155# -req "HEAD" \
156# -scheme "https" \
157# -url "/test12.html" \
158# -hdr "content-length" "0"
159# rxhdrs
160# expect resp.status == 200
161# rxdata -all
162# expect resp.bodylen == 0
163# } -run
164#
165# # third request sends a body with a GET
166# stream 5 {
167# barrier b3 sync
168# txreq \
169# -req "HEAD" \
170# -scheme "https" \
171# -url "/test13.html" \
172# -nostrend \
173# -body "this must be delivered, like it or not"
174# rxwinup
175# rxhdrs
176# expect resp.status == 200
177# rxdata -all
178# expect resp.bodylen == 0
179# } -run
180#
181# # fourth request is valid and advertises C-L:0, and close, and is
182# # followed by a string "this is not sent\r\n\r\n" which must be
183# # dropped.
184# stream 7 {
185# barrier b4 sync
186# txreq \
187# -req "HEAD" \
188# -scheme "https" \
189# -url "/test14.html" \
190# -hdr "content-length" "0" \
191# -nostrend
192# txdata -data "this is sent and ignored"
193# rxwinup
194# rxhdrs
195# expect resp.status == 200
196# rxdata -all
197# expect resp.bodylen == 0
198# } -run
199#} -run
200
201# POST requests
202client c3h2 -connect ${h1_feh2_sock} {
203 txpri
204 stream 0 {
205 txsettings
206 rxsettings
207 txsettings -ack
208 rxwinup
209 rxsettings
210 expect settings.ack == true
211 } -run
212
213 # first request is valid
214 stream 1 {
215 txreq \
216 -req "POST" \
217 -scheme "https" \
218 -url "/test21.html"
219 rxhdrs
220 expect resp.status == 200
221 rxdata -all
222 expect resp.body == "response 1"
223 } -run
224
225 # second request is valid and advertises C-L:0
226 stream 3 {
227 barrier b2 sync
228 txreq \
229 -req "POST" \
230 -scheme "https" \
231 -url "/test22.html" \
232 -hdr "content-length" "0"
233 rxhdrs
234 expect resp.status == 200
235 rxdata -all
236 expect resp.body == "response 2"
237 } -run
238
239 # third request sends a body with a GET
240 stream 5 {
241 barrier b3 sync
242 txreq \
243 -req "POST" \
244 -scheme "https" \
245 -url "/test23.html" \
246 -nostrend \
247 -body "this must be delivered, like it or not"
248 rxwinup
249 rxhdrs
250 expect resp.status == 200
251 rxdata -all
252 expect resp.body == "response 3"
253 } -run
254
255 # fourth request is valid and advertises C-L:0, and close, and is
256 # followed by a string "this is not sent\r\n\r\n" which must be
257 # dropped.
258 stream 7 {
259 barrier b4 sync
260 txreq \
261 -req "POST" \
262 -scheme "https" \
263 -url "/test24.html" \
264 -hdr "content-length" "0" \
265 -nostrend
266 txdata -data "this is sent and ignored"
267 rxwinup
268 rxhdrs
269 expect resp.status == 200
270 rxdata -all
271 expect resp.body == "response 4"
272 } -run
273} -run