blob: d2d0b9dc98fe68aa66df262588ee1d55c2fec735 [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
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
Christopher Faulet8f161482018-12-19 11:49:39 +010044 ${no-htx} option http-use-htx
Willy Tarreau7b8d2032018-12-13 19:35:29 +010045 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
Willy Tarreau7b8d2032018-12-13 19:35:29 +010061 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
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100134# rxsettings
135# expect settings.ack == true
136# } -run
137#
138# # first request is valid
139# stream 1 {
140# txreq \
141# -req "HEAD" \
142# -scheme "https" \
143# -url "/test11.html"
144# rxhdrs
145# expect resp.status == 200
146# rxdata -all
147# expect resp.bodylen == 0
148# } -run
149#
150# # second request is valid and advertises C-L:0
151# stream 3 {
152# barrier b2 sync
153# txreq \
154# -req "HEAD" \
155# -scheme "https" \
156# -url "/test12.html" \
157# -hdr "content-length" "0"
158# rxhdrs
159# expect resp.status == 200
160# rxdata -all
161# expect resp.bodylen == 0
162# } -run
163#
164# # third request sends a body with a GET
165# stream 5 {
166# barrier b3 sync
167# txreq \
168# -req "HEAD" \
169# -scheme "https" \
170# -url "/test13.html" \
171# -nostrend \
172# -body "this must be delivered, like it or not"
173# rxwinup
174# rxhdrs
175# expect resp.status == 200
176# rxdata -all
177# expect resp.bodylen == 0
178# } -run
179#
180# # fourth request is valid and advertises C-L:0, and close, and is
181# # followed by a string "this is not sent\r\n\r\n" which must be
182# # dropped.
183# stream 7 {
184# barrier b4 sync
185# txreq \
186# -req "HEAD" \
187# -scheme "https" \
188# -url "/test14.html" \
189# -hdr "content-length" "0" \
190# -nostrend
191# txdata -data "this is sent and ignored"
192# rxwinup
193# rxhdrs
194# expect resp.status == 200
195# rxdata -all
196# expect resp.bodylen == 0
197# } -run
198#} -run
199
200# POST requests
201client c3h2 -connect ${h1_feh2_sock} {
202 txpri
203 stream 0 {
204 txsettings
205 rxsettings
206 txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100207 rxsettings
208 expect settings.ack == true
209 } -run
210
211 # first request is valid
212 stream 1 {
213 txreq \
214 -req "POST" \
215 -scheme "https" \
216 -url "/test21.html"
217 rxhdrs
218 expect resp.status == 200
219 rxdata -all
220 expect resp.body == "response 1"
221 } -run
222
223 # second request is valid and advertises C-L:0
224 stream 3 {
225 barrier b2 sync
226 txreq \
227 -req "POST" \
228 -scheme "https" \
229 -url "/test22.html" \
230 -hdr "content-length" "0"
231 rxhdrs
232 expect resp.status == 200
233 rxdata -all
234 expect resp.body == "response 2"
235 } -run
236
237 # third request sends a body with a GET
238 stream 5 {
239 barrier b3 sync
240 txreq \
241 -req "POST" \
242 -scheme "https" \
243 -url "/test23.html" \
244 -nostrend \
245 -body "this must be delivered, like it or not"
246 rxwinup
247 rxhdrs
248 expect resp.status == 200
249 rxdata -all
250 expect resp.body == "response 3"
251 } -run
252
253 # fourth request is valid and advertises C-L:0, and close, and is
254 # followed by a string "this is not sent\r\n\r\n" which must be
255 # dropped.
256 stream 7 {
257 barrier b4 sync
258 txreq \
259 -req "POST" \
260 -scheme "https" \
261 -url "/test24.html" \
262 -hdr "content-length" "0" \
263 -nostrend
264 txdata -data "this is sent and ignored"
265 rxwinup
266 rxhdrs
267 expect resp.status == 200
268 rxdata -all
269 expect resp.body == "response 4"
270 } -run
271} -run