blob: 34d8976c09c2b29fecdda5a7e05efd79738497be [file] [log] [blame]
Tim Duesterhus721d6862019-06-17 16:10:07 +02001varnishtest "Compression sets Vary header"
2
Tim Duesterhus721d6862019-06-17 16:10:07 +02003#REQUIRE_OPTION=ZLIB|SLZ
4
5feature ignore_unknown_macro
6
7server s1 {
8 rxreq
9 expect req.url == "/plain/accept-encoding-gzip"
10 expect req.http.accept-encoding == "gzip"
11 txresp \
12 -hdr "Content-Type: text/plain" \
13 -bodylen 100
14
15 rxreq
16 expect req.url == "/plain/accept-encoding-invalid"
17 expect req.http.accept-encoding == "invalid"
18 txresp \
19 -hdr "Content-Type: text/plain" \
20 -bodylen 100
21
22 rxreq
23 expect req.url == "/plain/accept-encoding-null"
24 expect req.http.accept-encoding == "<undef>"
25 txresp \
26 -hdr "Content-Type: text/plain" \
27 -bodylen 100
28
29 rxreq
30 expect req.url == "/html/accept-encoding-gzip"
31 expect req.http.accept-encoding == "gzip"
32 txresp \
33 -hdr "Content-Type: text/html" \
34 -bodylen 100
35
36 rxreq
37 expect req.url == "/html/accept-encoding-invalid"
38 expect req.http.accept-encoding == "invalid"
39 txresp \
40 -hdr "Content-Type: text/html" \
41 -bodylen 100
42
43
44 rxreq
45 expect req.url == "/html/accept-encoding-null"
46 expect req.http.accept-encoding == "<undef>"
47 txresp \
48 -hdr "Content-Type: text/html" \
49 -bodylen 100
50
51 rxreq
52 expect req.url == "/dup-etag/accept-encoding-gzip"
53 expect req.http.accept-encoding == "gzip"
54 txresp \
55 -hdr "Content-Type: text/plain" \
56 -hdr "ETag: \"123\"" \
57 -hdr "ETag: \"123\"" \
58 -bodylen 100
59} -repeat 2 -start
60
61
62haproxy h1 -conf {
Willy Tarreaue1465c12021-05-09 14:41:41 +020063 global
64 # WT: limit false-positives causing "HTTP header incomplete" due to
65 # idle server connections being randomly used and randomly expiring
66 # under us.
67 tune.idle-pool.shared off
68
Tim Duesterhus721d6862019-06-17 16:10:07 +020069 defaults
70 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010071 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
72 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
73 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Tim Duesterhus721d6862019-06-17 16:10:07 +020074
75 frontend fe-gzip
76 bind "fd@${fe_gzip}"
77 default_backend be-gzip
78
79 backend be-gzip
80 compression algo gzip
81 compression type text/plain
82 server www ${s1_addr}:${s1_port}
83
84 frontend fe-nothing
85 bind "fd@${fe_nothing}"
86 default_backend be-nothing
87
88 backend be-nothing
89 server www ${s1_addr}:${s1_port}
90} -start
91
92client c1 -connect ${h1_fe_gzip_sock} {
93 txreq -url "/plain/accept-encoding-gzip" \
94 -hdr "Accept-Encoding: gzip"
95 rxresp
96 expect resp.status == 200
97 expect resp.http.content-encoding == "gzip"
98 expect resp.http.vary == "Accept-Encoding"
99 gunzip
100 expect resp.bodylen == 100
101
102 txreq -url "/plain/accept-encoding-invalid" \
103 -hdr "Accept-Encoding: invalid"
104 rxresp
105 expect resp.status == 200
106 expect resp.http.vary == "<undef>"
107 expect resp.bodylen == 100
108
109 txreq -url "/plain/accept-encoding-null"
110 rxresp
111 expect resp.status == 200
112 expect resp.http.vary == "<undef>"
113 expect resp.bodylen == 100
114
115 txreq -url "/html/accept-encoding-gzip" \
116 -hdr "Accept-Encoding: gzip"
117 rxresp
118 expect resp.status == 200
119 expect resp.http.vary == "<undef>"
120 expect resp.bodylen == 100
121
122 txreq -url "/html/accept-encoding-invalid" \
123 -hdr "Accept-Encoding: invalid"
124 rxresp
125 expect resp.status == 200
126 expect resp.http.vary == "<undef>"
127 expect resp.bodylen == 100
128
129 txreq -url "/html/accept-encoding-null"
130 rxresp
131 expect resp.status == 200
132 expect resp.http.vary == "<undef>"
133 expect resp.bodylen == 100
134
135 txreq -url "/dup-etag/accept-encoding-gzip" \
136 -hdr "Accept-Encoding: gzip"
137 rxresp
138 expect resp.status == 200
139 expect resp.http.vary == "<undef>"
140 expect resp.bodylen == 100
141} -run
142
143# This Client duplicates c1, against the "nothing" frontend, ensuring no Vary header is ever set.
144client c2 -connect ${h1_fe_nothing_sock} {
145 txreq -url "/plain/accept-encoding-gzip" \
146 -hdr "Accept-Encoding: gzip"
147 rxresp
148 expect resp.status == 200
149 expect resp.http.vary == "<undef>"
150 expect resp.bodylen == 100
151
152 txreq -url "/plain/accept-encoding-invalid" \
153 -hdr "Accept-Encoding: invalid"
154 rxresp
155 expect resp.status == 200
156 expect resp.http.vary == "<undef>"
157 expect resp.bodylen == 100
158
159 txreq -url "/plain/accept-encoding-null"
160 rxresp
161 expect resp.status == 200
162 expect resp.http.vary == "<undef>"
163 expect resp.bodylen == 100
164
165 txreq -url "/html/accept-encoding-gzip" \
166 -hdr "Accept-Encoding: gzip"
167 rxresp
168 expect resp.status == 200
169 expect resp.http.vary == "<undef>"
170 expect resp.bodylen == 100
171
172 txreq -url "/html/accept-encoding-invalid" \
173 -hdr "Accept-Encoding: invalid"
174 rxresp
175 expect resp.status == 200
176 expect resp.http.vary == "<undef>"
177 expect resp.bodylen == 100
178
179 txreq -url "/html/accept-encoding-null"
180 rxresp
181 expect resp.status == 200
182 expect resp.http.vary == "<undef>"
183 expect resp.bodylen == 100
184
185 txreq -url "/dup-etag/accept-encoding-gzip" \
186 -hdr "Accept-Encoding: gzip"
187 rxresp
188 expect resp.status == 200
189 expect resp.http.vary == "<undef>"
190 expect resp.bodylen == 100
191} -run