blob: 6f36545f265ebaf0c419c1a1a5362095a960455e [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 {
Willy Tarreaue1465c12021-05-09 14:41:41 +020033 global
34 # WT: limit false-positives causing "HTTP header incomplete" due to
35 # idle server connections being randomly used and randomly expiring
36 # under us.
37 tune.idle-pool.shared off
38
Christopher Faulet475fab32021-02-10 10:20:26 +010039 defaults
40 mode http
41 ${no-htx} option http-use-htx
42 timeout connect 1s
43 timeout client 1s
44 timeout server 1s
45
46 listen fe1
47 bind "fd@${fe1}"
48 # Rewrite the method to be sure to get the response payload
49 # on the server side
50 http-request set-method GET
51 server s1 ${s1_addr}:${s1_port}
52
53 listen int
54 bind "fd@${int}" proto h2
55 # Rewrite the method to be sure to get the response payload
56 # on the server side
57 http-request set-method GET
58 server s1 ${s1_addr}:${s1_port}
59 #server s1 ${h1_fe1_addr}:${h1_fe1_port}
60
61 listen fe2
62 bind "fd@${fe2}"
63 server s1 ${h1_int_addr}:${h1_int_port} proto h2
64} -start
65
66client c1 -connect ${h1_fe1_sock} {
67 txreq \
68 -req "HEAD" \
69 -url "/req1"
70 rxresp
71 expect resp.status == 200
72 expect resp.body == ""
73
74 txreq \
75 -req "HEAD" \
76 -url "/req2"
77 rxresp
78 expect resp.status == 200
79 expect resp.body == ""
80
81 txreq \
82 -req "HEAD" \
83 -url "/req3"
84 rxresp
85 expect resp.status == 200
86 expect resp.body == ""
87
88 # The last one have a body and validate the connection was not closed
89 # unexpectedly and no payload was received for previous requests
90 txreq \
91 -req "GET" \
92 -url "/req4"
93 rxresp
94 expect resp.status == 200
95 expect resp.body == "last response"
96} -run
97
98client c2 -connect ${h1_fe2_sock} {
99 txreq \
100 -req "HEAD" \
101 -url "/req1"
102 rxresp
103 expect resp.status == 200
104 expect resp.body == ""
105
106 txreq \
107 -req "HEAD" \
108 -url "/req2"
109 rxresp
110 expect resp.status == 200
111 expect resp.body == ""
112
113 txreq \
114 -req "HEAD" \
115 -url "/req3"
116 rxresp
117 expect resp.status == 200
118 expect resp.body == ""
119
120 # The last one have a body and validate the connection was not closed
121 # unexpectedly and no payload was received for previous requests
122 txreq \
123 -req "GET" \
124 -url "/req4"
125 rxresp
126 expect resp.status == 200
127 expect resp.body == "last response"
128} -run