blob: 0d2b1e5f225159bb8b4c503f2c63b085273f4759 [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 {
Willy Tarreaue1465c12021-05-09 14:41:41 +020037 global
38 # WT: limit false-positives causing "HTTP header incomplete" due to
39 # idle server connections being randomly used and randomly expiring
40 # under us.
41 tune.idle-pool.shared off
42
Willy Tarreau7b8d2032018-12-13 19:35:29 +010043 defaults
44 #log stdout format raw daemon
45 mode http
Willy Tarreau4a7b5b32018-12-14 09:51:48 +010046 option http-buffer-request
Christopher Faulet8f161482018-12-19 11:49:39 +010047 ${no-htx} option http-use-htx
Willy Tarreau7b8d2032018-12-13 19:35:29 +010048 timeout connect 1s
49 timeout client 1s
50 timeout server 1s
51
52 listen feh1
53 bind "fd@${feh1}"
54 bind "fd@${feh2}" proto h2
55 server s1 ${s1_addr}:${s1_port}
56} -start
57
58client c1h2 -connect ${h1_feh2_sock} {
59 txpri
60 stream 0 {
61 txsettings
62 rxsettings
63 txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +010064 rxsettings
65 expect settings.ack == true
66 } -run
67
68 # first request is valid
69 stream 1 {
70 txreq \
71 -req "GET" \
72 -scheme "https" \
73 -url "/test1.html"
74 rxhdrs
75 expect resp.status == 200
76 rxdata -all
77 expect resp.body == "response 1"
78 } -run
79
80 # second request is valid and advertises C-L:0
81 stream 3 {
82 barrier b2 sync
83 txreq \
84 -req "GET" \
85 -scheme "https" \
86 -url "/test2.html" \
87 -hdr "content-length" "0"
88 rxhdrs
89 expect resp.status == 200
90 rxdata -all
91 expect resp.body == "response 2"
92 } -run
93
94 # third request sends a body with a GET
95 stream 5 {
96 barrier b3 sync
97 txreq \
98 -req "GET" \
99 -scheme "https" \
100 -url "/test3.html" \
101 -nostrend \
102 -body "this must be delivered, like it or not"
103 rxwinup
104 rxhdrs
105 expect resp.status == 200
106 rxdata -all
107 expect resp.body == "response 3"
108 } -run
109
Willy Tarreau1915ca22019-01-24 11:49:37 +0100110 # fourth request is valid and advertises C-L:2, and close, and is
111 # followed by a string "this is not sent\r\n\r\n" which causes a
112 # stream error of type PROTOCOL_ERROR.
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100113 stream 7 {
114 barrier b4 sync
115 txreq \
116 -req "GET" \
117 -scheme "https" \
118 -url "/test4.html" \
Willy Tarreau1915ca22019-01-24 11:49:37 +0100119 -hdr "content-length" "2" \
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100120 -nostrend
121 txdata -data "this is sent and ignored"
Willy Tarreau1915ca22019-01-24 11:49:37 +0100122 rxrst
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100123 } -run
124} -run
125
126# HEAD requests : don't work well yet
127#client c2h2 -connect ${h1_feh2_sock} {
128# txpri
129# stream 0 {
130# txsettings
131# rxsettings
132# txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100133# rxsettings
134# expect settings.ack == true
135# } -run
136#
137# # first request is valid
138# stream 1 {
139# txreq \
140# -req "HEAD" \
141# -scheme "https" \
142# -url "/test11.html"
143# rxhdrs
144# expect resp.status == 200
145# rxdata -all
146# expect resp.bodylen == 0
147# } -run
148#
149# # second request is valid and advertises C-L:0
150# stream 3 {
151# barrier b2 sync
152# txreq \
153# -req "HEAD" \
154# -scheme "https" \
155# -url "/test12.html" \
156# -hdr "content-length" "0"
157# rxhdrs
158# expect resp.status == 200
159# rxdata -all
160# expect resp.bodylen == 0
161# } -run
162#
163# # third request sends a body with a GET
164# stream 5 {
165# barrier b3 sync
166# txreq \
167# -req "HEAD" \
168# -scheme "https" \
169# -url "/test13.html" \
170# -nostrend \
171# -body "this must be delivered, like it or not"
172# rxwinup
173# rxhdrs
174# expect resp.status == 200
175# rxdata -all
176# expect resp.bodylen == 0
177# } -run
178#
179# # fourth request is valid and advertises C-L:0, and close, and is
180# # followed by a string "this is not sent\r\n\r\n" which must be
181# # dropped.
182# stream 7 {
183# barrier b4 sync
184# txreq \
185# -req "HEAD" \
186# -scheme "https" \
187# -url "/test14.html" \
188# -hdr "content-length" "0" \
189# -nostrend
190# txdata -data "this is sent and ignored"
191# rxwinup
192# rxhdrs
193# expect resp.status == 200
194# rxdata -all
195# expect resp.bodylen == 0
196# } -run
197#} -run
198
199# POST requests
200client c3h2 -connect ${h1_feh2_sock} {
201 txpri
202 stream 0 {
203 txsettings
204 rxsettings
205 txsettings -ack
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100206 rxsettings
207 expect settings.ack == true
208 } -run
209
210 # first request is valid
211 stream 1 {
212 txreq \
213 -req "POST" \
214 -scheme "https" \
215 -url "/test21.html"
216 rxhdrs
217 expect resp.status == 200
218 rxdata -all
219 expect resp.body == "response 1"
220 } -run
221
222 # second request is valid and advertises C-L:0
223 stream 3 {
224 barrier b2 sync
225 txreq \
226 -req "POST" \
227 -scheme "https" \
228 -url "/test22.html" \
229 -hdr "content-length" "0"
230 rxhdrs
231 expect resp.status == 200
232 rxdata -all
233 expect resp.body == "response 2"
234 } -run
235
236 # third request sends a body with a GET
237 stream 5 {
238 barrier b3 sync
239 txreq \
240 -req "POST" \
241 -scheme "https" \
242 -url "/test23.html" \
243 -nostrend \
244 -body "this must be delivered, like it or not"
245 rxwinup
246 rxhdrs
247 expect resp.status == 200
248 rxdata -all
249 expect resp.body == "response 3"
250 } -run
251
Willy Tarreau1915ca22019-01-24 11:49:37 +0100252 # fourth request is valid and advertises C-L:2, and close, and is
253 # followed by a string "this is not sent\r\n\r\n" which results
254 # in a stream error.
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100255 stream 7 {
256 barrier b4 sync
257 txreq \
258 -req "POST" \
259 -scheme "https" \
260 -url "/test24.html" \
Willy Tarreau1915ca22019-01-24 11:49:37 +0100261 -hdr "content-length" "2" \
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100262 -nostrend
263 txdata -data "this is sent and ignored"
Willy Tarreau1915ca22019-01-24 11:49:37 +0100264 rxrst
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100265 } -run
266} -run