blob: 322dfe29acabd9d6ffc9f25cb04c8674a858e687 [file] [log] [blame]
Christopher Fauletc7e94922021-09-28 15:55:55 +02001varnishtest "A test to validate Transfer-Encoding header conformance to the spec"
Christopher Fauletc7e94922021-09-28 15:55:55 +02002
Tim Duesterhus41922af2021-11-04 21:12:14 +01003feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'"
4feature ignore_unknown_macro
Christopher Fauletc7e94922021-09-28 15:55:55 +02005
6server s1 {
7 rxreq
8 expect req.http.content-length == <undef>
9 expect req.http.transfer-encoding == "chunked"
10 expect req.bodylen == 0
11 expect req.body == ""
12 txresp -status 200
13
14 accept
15 rxreq
16 expect req.http.content-length == <undef>
17 expect req.http.transfer-encoding == "chunked"
18 expect req.bodylen == 0
19 expect req.body == ""
20 txresp -status 200
21
22 accept
23 rxreq
24 send "HTTP/1.0 200 Ok\r\n"
25 send "Transfer-Encoding: chunked\r\n\r\n"
26 send "0\r\n\r\n"
27
28 accept
29 rxreq
30 send "HTTP/1.1 200 Ok\r\n"
31 send "Transfer-Encoding: chunked\r\n"
32 send "Content-Length: 30\r\n\r\n"
33 send "0\r\n\r\nResponse splitting attach"
34
35 accept
36 rxreq
37 expect req.url == "/1"
38 expect req.http.transfer-encoding == "chunked"
39 expect req.http.te == "trailers"
40 txresp
41
42 rxreq
43 expect req.url == "/2"
44 expect req.http.transfer-encoding == "chunked"
45 expect req.http.te == <undef>
46 txresp
47
48 rxreq
49 expect req.url == "/3"
50 expect req.http.transfer-encoding == "chunked"
51 expect req.http.te == <undef>
52 txresp
53} -start
54
55server s2 {
56 rxreq
57 txresp -nolen \
58 -hdr "Transfer-Encoding: chunked, chunked" \
59 -body "0\r\n\r\n"
60
61 accept
62 rxreq
63 txresp -nolen \
64 -hdr "Transfer-Encoding: chunked, gzip, chunked" \
65 -body "0\r\n\r\n"
66
67 accept
68 rxreq
69 txresp -nolen \
70 -hdr "Transfer-Encoding: chunked, gzip" \
71 -body "0\r\n\r\n"
72
73 accept
74 rxreq
75 txresp \
76 -hdr "Transfer-Encoding: gzip"
77} -start
78
79haproxy h1 -conf {
80 defaults
81 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010082 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
83 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
84 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Christopher Fauletc7e94922021-09-28 15:55:55 +020085
86 listen fe1
87 bind "fd@${fe1}"
88 server s1 ${s1_addr}:${s1_port}
89
90 listen fe2
91 bind "fd@${fe2}"
92 server s2 ${s2_addr}:${s2_port}
93} -start
94
95client c1 -connect ${h1_fe1_sock} {
96 txreq -method POST -nolen \
97 -hdr "Transfer-Encoding: chunked" \
98 -hdr "Content-Length: 31" \
99 -body "0\r\n\r\nGET /smuggled HTTP/1.1\r\n\r\n"
100 rxresp
101 expect resp.status == 200
102 expect resp.http.connection == "close"
103 expect_close
104} -run
105
106client c2 -connect ${h1_fe1_sock} {
107 send "POST / HTTP/1.0\r\n"
108 send "Transfer-Encoding: chunked\r\n\r\n"
109 send "0\r\n\r\n"
110 rxresp
111 expect resp.status == 200
112 expect_close
113} -run
114
115client c3 -connect ${h1_fe1_sock} {
116 txreq
117 rxresp
118 expect resp.status == 200
119 expect resp.http.content-length == <undef>
120 expect resp.http.transfer-encoding == "chunked"
121 expect resp.bodylen == 0
122 expect resp.body == ""
123 expect_close
124} -run
125
126client c4 -connect ${h1_fe1_sock} {
127 txreq
128 rxresp
129 expect resp.status == 200
130 expect resp.http.content-length == <undef>
131 expect resp.http.transfer-encoding == "chunked"
132 expect resp.bodylen == 0
133 expect resp.body == ""
134} -run
135
136client c5 -connect ${h1_fe1_sock} {
137 txreq -method POST -url "/1" -nolen \
138 -hdr "Transfer-Encoding: chunked" \
139 -hdr "TE: trailers, gzip" \
140 -body "0\r\n\r\n"
141 rxresp
142 expect resp.status == 200
143
144 txreq -method POST -url "/2" -nolen \
145 -hdr "Transfer-Encoding: chunked" \
146 -hdr "TE: gzip" \
147 -body "0\r\n\r\n"
148 rxresp
149 expect resp.status == 200
150
151 txreq -method POST -url "/3" -nolen \
152 -hdr "Transfer-Encoding: chunked" \
153 -hdr "TE: trailers;q=0.5" \
154 -body "0\r\n\r\n"
155 rxresp
156 expect resp.status == 200
157} -run
158
159client c6 -connect ${h1_fe1_sock} {
160 txreq -nolen \
161 -hdr "Transfer-Encoding: chunked, chunked" \
162 -body "0\r\n\r\n"
163 rxresp
164 expect resp.status == 400
165} -run
166
167client c7 -connect ${h1_fe1_sock} {
168 txreq -nolen \
169 -hdr "Transfer-Encoding: chunked, gzip, chunked" \
170 -body "0\r\n\r\n"
171 rxresp
172 expect resp.status == 400
173} -run
174
175client c8 -connect ${h1_fe1_sock} {
176 txreq -nolen \
177 -hdr "Transfer-Encoding: chunked, gzip" \
178 -body "0\r\n\r\n"
179 rxresp
180 expect resp.status == 400
181} -run
182
183client c9 -connect ${h1_fe1_sock} {
184 txreq \
185 -hdr "Transfer-Encoding: gzip"
186 rxresp
187 expect resp.status == 400
188} -run
189
190client c10 -connect ${h1_fe1_sock} {
191 txreq -nolen \
192 -hdr "Transfer-Encoding: gzip, chunked" \
193 -body "0\r\n\r\n"
194 rxresp
195 expect resp.status == 422
196} -run
197
198client c11 -connect ${h1_fe2_sock} {
199 txreq
200 rxresp
201 expect resp.status == 502
202} -run -repeat 4