blob: f45a7d61b8e03f11eb578becba0cfe121862c650 [file] [log] [blame]
Christopher Faulet475fab32021-02-10 10:20:26 +01001varnishtest "A test to be sure payload is skipped for bodyless responses"
2feature ignore_unknown_macro
3
4#REQUIRE_VERSION=2.4
5
6server s1 {
7 rxreq
8 txresp \
9 -status 200 \
10 -body "skipped data"
11
12 rxreq
13 txresp \
14 -status 200 \
15 -bodylen 20000
16
17 rxreq
18 txresp \
19 -status 200 \
20 -nolen -hdr "Transfer-Encoding: chunked"
21 chunkedlen 15
22 chunkedlen 1024
23 chunkedlen 4048
24 chunkedlen 0
25
26 rxreq
27 txresp \
28 -status 200 \
29 -body "last response"
30} -repeat 2 -start
31
32haproxy h1 -conf {
33 defaults
34 mode http
35 ${no-htx} option http-use-htx
36 timeout connect 1s
37 timeout client 1s
38 timeout server 1s
39
40 listen fe1
41 bind "fd@${fe1}"
42 # Rewrite the method to be sure to get the response payload
43 # on the server side
44 http-request set-method GET
45 server s1 ${s1_addr}:${s1_port}
46
47 listen int
48 bind "fd@${int}" proto h2
49 # Rewrite the method to be sure to get the response payload
50 # on the server side
51 http-request set-method GET
52 server s1 ${s1_addr}:${s1_port}
53 #server s1 ${h1_fe1_addr}:${h1_fe1_port}
54
55 listen fe2
56 bind "fd@${fe2}"
57 server s1 ${h1_int_addr}:${h1_int_port} proto h2
58} -start
59
60client c1 -connect ${h1_fe1_sock} {
61 txreq \
62 -req "HEAD" \
63 -url "/req1"
64 rxresp
65 expect resp.status == 200
66 expect resp.body == ""
67
68 txreq \
69 -req "HEAD" \
70 -url "/req2"
71 rxresp
72 expect resp.status == 200
73 expect resp.body == ""
74
75 txreq \
76 -req "HEAD" \
77 -url "/req3"
78 rxresp
79 expect resp.status == 200
80 expect resp.body == ""
81
82 # The last one have a body and validate the connection was not closed
83 # unexpectedly and no payload was received for previous requests
84 txreq \
85 -req "GET" \
86 -url "/req4"
87 rxresp
88 expect resp.status == 200
89 expect resp.body == "last response"
90} -run
91
92client c2 -connect ${h1_fe2_sock} {
93 txreq \
94 -req "HEAD" \
95 -url "/req1"
96 rxresp
97 expect resp.status == 200
98 expect resp.body == ""
99
100 txreq \
101 -req "HEAD" \
102 -url "/req2"
103 rxresp
104 expect resp.status == 200
105 expect resp.body == ""
106
107 txreq \
108 -req "HEAD" \
109 -url "/req3"
110 rxresp
111 expect resp.status == 200
112 expect resp.body == ""
113
114 # The last one have a body and validate the connection was not closed
115 # unexpectedly and no payload was received for previous requests
116 txreq \
117 -req "GET" \
118 -url "/req4"
119 rxresp
120 expect resp.status == 200
121 expect resp.body == "last response"
122} -run