blob: 481aded12aeea51ca4dba5de71d70f0c284e1995 [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
Willy Tarreau1915ca22019-01-24 11:49:37 +010033 # the next request is never received
Willy Tarreau7b8d2032018-12-13 19:35:29 +010034} -repeat 2 -start
35
36haproxy h1 -conf {
37 defaults
38 #log stdout format raw daemon
39 mode http
Willy Tarreau4a7b5b32018-12-14 09:51:48 +010040 option http-buffer-request
Christopher Faulet8f161482018-12-19 11:49:39 +010041 ${no-htx} option http-use-htx
Willy Tarreau7b8d2032018-12-13 19:35:29 +010042 timeout connect 1s
43 timeout client 1s
44 timeout server 1s
45
46 listen feh1
47 bind "fd@${feh1}"
48 bind "fd@${feh2}" proto h2
49 server s1 ${s1_addr}:${s1_port}
50} -start
51
52client c1h2 -connect ${h1_feh2_sock} {
53 txpri
54 stream 0 {
55 txsettings
56 rxsettings
57 txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +010058 rxsettings
59 expect settings.ack == true
60 } -run
61
62 # first request is valid
63 stream 1 {
64 txreq \
65 -req "GET" \
66 -scheme "https" \
67 -url "/test1.html"
68 rxhdrs
69 expect resp.status == 200
70 rxdata -all
71 expect resp.body == "response 1"
72 } -run
73
74 # second request is valid and advertises C-L:0
75 stream 3 {
76 barrier b2 sync
77 txreq \
78 -req "GET" \
79 -scheme "https" \
80 -url "/test2.html" \
81 -hdr "content-length" "0"
82 rxhdrs
83 expect resp.status == 200
84 rxdata -all
85 expect resp.body == "response 2"
86 } -run
87
88 # third request sends a body with a GET
89 stream 5 {
90 barrier b3 sync
91 txreq \
92 -req "GET" \
93 -scheme "https" \
94 -url "/test3.html" \
95 -nostrend \
96 -body "this must be delivered, like it or not"
97 rxwinup
98 rxhdrs
99 expect resp.status == 200
100 rxdata -all
101 expect resp.body == "response 3"
102 } -run
103
Willy Tarreau1915ca22019-01-24 11:49:37 +0100104 # fourth request is valid and advertises C-L:2, and close, and is
105 # followed by a string "this is not sent\r\n\r\n" which causes a
106 # stream error of type PROTOCOL_ERROR.
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100107 stream 7 {
108 barrier b4 sync
109 txreq \
110 -req "GET" \
111 -scheme "https" \
112 -url "/test4.html" \
Willy Tarreau1915ca22019-01-24 11:49:37 +0100113 -hdr "content-length" "2" \
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100114 -nostrend
115 txdata -data "this is sent and ignored"
Willy Tarreau1915ca22019-01-24 11:49:37 +0100116 rxrst
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100117 } -run
118} -run
119
120# HEAD requests : don't work well yet
121#client c2h2 -connect ${h1_feh2_sock} {
122# txpri
123# stream 0 {
124# txsettings
125# rxsettings
126# txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100127# rxsettings
128# expect settings.ack == true
129# } -run
130#
131# # first request is valid
132# stream 1 {
133# txreq \
134# -req "HEAD" \
135# -scheme "https" \
136# -url "/test11.html"
137# rxhdrs
138# expect resp.status == 200
139# rxdata -all
140# expect resp.bodylen == 0
141# } -run
142#
143# # second request is valid and advertises C-L:0
144# stream 3 {
145# barrier b2 sync
146# txreq \
147# -req "HEAD" \
148# -scheme "https" \
149# -url "/test12.html" \
150# -hdr "content-length" "0"
151# rxhdrs
152# expect resp.status == 200
153# rxdata -all
154# expect resp.bodylen == 0
155# } -run
156#
157# # third request sends a body with a GET
158# stream 5 {
159# barrier b3 sync
160# txreq \
161# -req "HEAD" \
162# -scheme "https" \
163# -url "/test13.html" \
164# -nostrend \
165# -body "this must be delivered, like it or not"
166# rxwinup
167# rxhdrs
168# expect resp.status == 200
169# rxdata -all
170# expect resp.bodylen == 0
171# } -run
172#
173# # fourth request is valid and advertises C-L:0, and close, and is
174# # followed by a string "this is not sent\r\n\r\n" which must be
175# # dropped.
176# stream 7 {
177# barrier b4 sync
178# txreq \
179# -req "HEAD" \
180# -scheme "https" \
181# -url "/test14.html" \
182# -hdr "content-length" "0" \
183# -nostrend
184# txdata -data "this is sent and ignored"
185# rxwinup
186# rxhdrs
187# expect resp.status == 200
188# rxdata -all
189# expect resp.bodylen == 0
190# } -run
191#} -run
192
193# POST requests
194client c3h2 -connect ${h1_feh2_sock} {
195 txpri
196 stream 0 {
197 txsettings
198 rxsettings
199 txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100200 rxsettings
201 expect settings.ack == true
202 } -run
203
204 # first request is valid
205 stream 1 {
206 txreq \
207 -req "POST" \
208 -scheme "https" \
209 -url "/test21.html"
210 rxhdrs
211 expect resp.status == 200
212 rxdata -all
213 expect resp.body == "response 1"
214 } -run
215
216 # second request is valid and advertises C-L:0
217 stream 3 {
218 barrier b2 sync
219 txreq \
220 -req "POST" \
221 -scheme "https" \
222 -url "/test22.html" \
223 -hdr "content-length" "0"
224 rxhdrs
225 expect resp.status == 200
226 rxdata -all
227 expect resp.body == "response 2"
228 } -run
229
230 # third request sends a body with a GET
231 stream 5 {
232 barrier b3 sync
233 txreq \
234 -req "POST" \
235 -scheme "https" \
236 -url "/test23.html" \
237 -nostrend \
238 -body "this must be delivered, like it or not"
239 rxwinup
240 rxhdrs
241 expect resp.status == 200
242 rxdata -all
243 expect resp.body == "response 3"
244 } -run
245
Willy Tarreau1915ca22019-01-24 11:49:37 +0100246 # fourth request is valid and advertises C-L:2, and close, and is
247 # followed by a string "this is not sent\r\n\r\n" which results
248 # in a stream error.
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100249 stream 7 {
250 barrier b4 sync
251 txreq \
252 -req "POST" \
253 -scheme "https" \
254 -url "/test24.html" \
Willy Tarreau1915ca22019-01-24 11:49:37 +0100255 -hdr "content-length" "2" \
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100256 -nostrend
257 txdata -data "this is sent and ignored"
Willy Tarreau1915ca22019-01-24 11:49:37 +0100258 rxrst
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100259 } -run
260} -run