blob: 951a926fc4699f90f5106f6bfa9b0d1d38bb09eb [file] [log] [blame]
Christopher Faulet8f161482018-12-19 11:49:39 +01001varnishtest "HTTP request tests: H1 to H1 (HTX mode supported only for HAProxy >= 1.9)"
Willy Tarreau7b8d2032018-12-13 19:35:29 +01002#REQUIRE_VERSION=1.6
3
4# Run it with HAPROXY_PROGRAM=$PWD/haproxy varnishtest -l -k -t 1 "$1"
5
6feature ignore_unknown_macro
7
8server s1 {
9 rxreq
10 txresp \
11 -status 200 \
12 -body "response 1"
13
14 rxreq
15 txresp \
16 -status 200 \
17 -body "response 2"
18
19 rxreq
20 txresp \
21 -status 200 \
22 -body "response 3"
23
24 rxreq
25 txresp \
26 -status 200 \
27 -body "response 4"
Willy Tarreau99233162019-03-15 15:07:12 +010028} -repeat 2 -start
Willy Tarreau7b8d2032018-12-13 19:35:29 +010029
30haproxy h1 -conf {
31 defaults
32 mode http
Christopher Faulet8f161482018-12-19 11:49:39 +010033 ${no-htx} option http-use-htx
Willy Tarreau7b8d2032018-12-13 19:35:29 +010034 timeout connect 1s
35 timeout client 1s
36 timeout server 1s
37
38 listen feh1
39 bind "fd@${feh1}"
40 #bind "fd@${feh2}" proto h2
41 server s1 ${s1_addr}:${s1_port}
42} -start
43
44# GET requests
45client c1h1 -connect ${h1_feh1_sock} {
46 # first request is valid
47 txreq \
48 -req "GET" \
49 -url "/test1.html"
50 rxresp
51 expect resp.status == 200
52
53 # second request is valid and advertises C-L:0
54 txreq \
55 -req "GET" \
56 -url "/test2.html" \
57 -hdr "content-length: 0"
58 rxresp
59 expect resp.status == 200
60
61 # third request sends a body with a GET
62 txreq \
63 -req "GET" \
64 -url "/test3.html" \
65 -body "this must be delivered, like it or not"
66 rxresp
67 expect resp.status == 200
68
69 # fourth request is valid and advertises C-L:0, and close, and is
70 # followed by a string "this is not sent\r\n\r\n" which must be
71 # dropped.
72 txreq \
73 -req "GET" \
74 -url "/test4.html" \
75 -hdr "content-length: 0" \
76 -hdr "connection: close"
77 # "this is not sent"
78 sendhex "74787973207973206E6F742073656E740D0A0D0A"
79 rxresp
80 expect resp.status == 200
81
82 # the connection is expected to be closed and no more response must
83 # arrive here.
84 expect_close
85} -run
86
87# HEAD requests
88# Note: for now they fail with varnishtest, which expects the amount of
89# data advertised in the content-length response.
Willy Tarreau99233162019-03-15 15:07:12 +010090#client c2h1 -connect ${h1_feh1_sock} {
91# # first request is valid
92# txreq \
93# -req "HEAD" \
94# -url "/test11.html"
95# rxresp
96# expect resp.status == 200
97#
98# # second request is valid and advertises C-L:0
99# txreq \
100# -req "HEAD" \
101# -url "/test12.html" \
102# -hdr "content-length: 0"
103# rxresp
104# expect resp.status == 200
105#
106# # third request sends a body with a GET
107# txreq \
108# -req "GET" \
109# -url "/test13.html" \
110# -body "this must be delivered, like it or not"
111# rxresp
112# expect resp.status == 200
113#
114# # fourth request is valid and advertises C-L:0, and close, and is
115# # followed by a string "this is not sent\r\n\r\n" which must be
116# # dropped.
117# txreq \
118# -req "HEAD" \
119# -url "/test14.html" \
120# -hdr "content-length: 0" \
121# -hdr "connection: close"
122# # "this is not sent"
123# sendhex "74787973207973206E6F742073656E740D0A0D0A"
124# rxresp
125# expect resp.status == 200
126#
127# # the connection is expected to be closed and no more response must
128# # arrive here.
129# expect_close
130#} -run
Willy Tarreau7b8d2032018-12-13 19:35:29 +0100131
132client c1h1 -connect ${h1_feh1_sock} {
133 # first request is valid
134 txreq \
135 -req "POST" \
136 -url "/test21.html"
137 rxresp
138 expect resp.status == 200
139
140 # second request is valid and advertises C-L:0
141 txreq \
142 -req "POST" \
143 -url "/test22.html" \
144 -hdr "content-length: 0"
145 rxresp
146 expect resp.status == 200
147
148 # third request is valid and advertises (and sends) somme contents
149 txreq \
150 -req "POST" \
151 -url "/test23.html" \
152 -body "this is sent"
153 rxresp
154 expect resp.status == 200
155
156 # fourth request is valid and advertises C-L:0, and close, and is
157 # followed by a string "this is not sent\r\n\r\n" which must be
158 # dropped.
159 txreq \
160 -req "POST" \
161 -url "/test24.html" \
162 -hdr "content-length: 0" \
163 -hdr "connection: close"
164 # "this is not sent"
165 sendhex "74787973207973206E6F742073656E740D0A0D0A"
166 rxresp
167 expect resp.status == 200
168
169 # the connection is expected to be closed and no more response must
170 # arrive here.
171 expect_close
172} -run