blob: 48e7955fc4696545a86b74d5696632f3f8912866 [file] [log] [blame]
Tim Duesterhusb229f012019-01-29 16:38:56 +01001varnishtest "Compression converts strong ETags to weak ETags"
2
3#REQUIRE_VERSION=1.9
4#REQUIRE_OPTION=ZLIB|SLZ
5
6feature ignore_unknown_macro
7
8server s1 {
9 rxreq
10 expect req.url == "/strong"
11 expect req.http.accept-encoding == "gzip"
12 txresp \
13 -hdr "Content-Type: text/plain" \
14 -hdr "ETag: \"123\"" \
15 -bodylen 100
16
17 rxreq
18 expect req.url == "/weak"
19 expect req.http.accept-encoding == "gzip"
20 txresp \
21 -hdr "Content-Type: text/plain" \
22 -hdr "ETag: W/\"456\"" \
23 -bodylen 100
24
25 rxreq
26 expect req.url == "/weak-incorrect-quoting"
27 expect req.http.accept-encoding == "gzip"
28 txresp \
29 -hdr "Content-Type: text/plain" \
30 -hdr "ETag: \"W/789\"" \
31 -bodylen 100
32
33 rxreq
34 expect req.url == "/empty-strong"
35 expect req.http.accept-encoding == "gzip"
36 txresp \
37 -hdr "Content-Type: text/plain" \
38 -hdr "ETag: \"\"" \
39 -bodylen 100
40
41 rxreq
42 expect req.url == "/empty-weak"
43 expect req.http.accept-encoding == "gzip"
44 txresp \
45 -hdr "Content-Type: text/plain" \
46 -hdr "ETag: W/\"\"" \
47 -bodylen 100
48
49 rxreq
50 expect req.url == "/invalid1"
51 expect req.http.accept-encoding == "gzip"
52 txresp \
53 -hdr "Content-Type: text/plain" \
54 -hdr "ETag: \"invalid" \
55 -bodylen 100
56
57 rxreq
58 expect req.url == "/invalid2"
59 expect req.http.accept-encoding == "gzip"
60 txresp \
61 -hdr "Content-Type: text/plain" \
62 -hdr "ETag: invalid\"" \
63 -bodylen 100
64
65 rxreq
66 expect req.url == "/invalid3"
67 expect req.http.accept-encoding == "gzip"
68 txresp \
69 -hdr "Content-Type: text/plain" \
70 -hdr "ETag: invalid" \
71 -bodylen 100
72
73 rxreq
74 expect req.url == "/invalid4"
75 expect req.http.accept-encoding == "gzip"
76 txresp \
77 -hdr "Content-Type: text/plain" \
78 -hdr "ETag: W/\"invalid" \
79 -bodylen 100
80
81 rxreq
82 expect req.url == "/invalid5"
83 expect req.http.accept-encoding == "gzip"
84 txresp \
85 -hdr "Content-Type: text/plain" \
86 -hdr "ETag: W/invalid\"" \
87 -bodylen 100
88
89 rxreq
90 expect req.url == "/invalid6"
91 expect req.http.accept-encoding == "gzip"
92 txresp \
93 -hdr "Content-Type: text/plain" \
94 -hdr "ETag: W/invalid" \
95 -bodylen 100
96
97 rxreq
98 expect req.url == "/multiple"
99 expect req.http.accept-encoding == "gzip"
100 txresp \
101 -hdr "Content-Type: text/plain" \
102 -hdr "ETag: \"one\"" \
103 -hdr "ETag: \"two\"" \
104 -bodylen 100
105} -start
106
107
108haproxy h1 -conf {
Willy Tarreaue1465c12021-05-09 14:41:41 +0200109 global
110 # WT: limit false-positives causing "HTTP header incomplete" due to
111 # idle server connections being randomly used and randomly expiring
112 # under us.
113 tune.idle-pool.shared off
114
Tim Duesterhusb229f012019-01-29 16:38:56 +0100115 defaults
116 mode http
117 ${no-htx} option http-use-htx
118 timeout connect 1s
119 timeout client 1s
120 timeout server 1s
121
122 frontend fe-gzip
123 bind "fd@${fe_gzip}"
124 default_backend be-gzip
125
126 backend be-gzip
127 compression algo gzip
128 compression type text/html text/plain
129 server www ${s1_addr}:${s1_port}
130} -start
131
132client c1 -connect ${h1_fe_gzip_sock} {
133 txreq -url "/strong" \
134 -hdr "Accept-Encoding: gzip"
135 rxresp
136 expect resp.status == 200
137 expect resp.http.content-encoding == "gzip"
138 expect resp.http.etag == "W/\"123\""
139 gunzip
140 expect resp.bodylen == 100
141
142 txreq -url "/weak" \
143 -hdr "Accept-Encoding: gzip"
144 rxresp
145 expect resp.status == 200
146 expect resp.http.content-encoding == "gzip"
147 expect resp.http.etag == "W/\"456\""
148 gunzip
149 expect resp.bodylen == 100
150
151 txreq -url "/weak-incorrect-quoting" \
152 -hdr "Accept-Encoding: gzip"
153 rxresp
154 expect resp.status == 200
155 expect resp.http.content-encoding == "gzip"
156 expect resp.http.etag == "W/\"W/789\""
157 gunzip
158 expect resp.bodylen == 100
159
160 txreq -url "/empty-strong" \
161 -hdr "Accept-Encoding: gzip"
162 rxresp
163 expect resp.status == 200
164 expect resp.http.content-encoding == "gzip"
165 expect resp.http.etag == "W/\"\""
166 gunzip
167 expect resp.bodylen == 100
168
169 txreq -url "/empty-weak" \
170 -hdr "Accept-Encoding: gzip"
171 rxresp
172 expect resp.status == 200
173 expect resp.http.content-encoding == "gzip"
174 expect resp.http.etag == "W/\"\""
175 gunzip
176 expect resp.bodylen == 100
177
178 txreq -url "/invalid1" \
179 -hdr "Accept-Encoding: gzip"
180 rxresp
181 expect resp.status == 200
182 expect resp.http.content-encoding == "<undef>"
183 expect resp.http.etag == "\"invalid"
184 expect resp.bodylen == 100
185
186 txreq -url "/invalid2" \
187 -hdr "Accept-Encoding: gzip"
188 rxresp
189 expect resp.status == 200
190 expect resp.http.content-encoding == "<undef>"
191 expect resp.http.etag == "invalid\""
192 expect resp.bodylen == 100
193
194 txreq -url "/invalid3" \
195 -hdr "Accept-Encoding: gzip"
196 rxresp
197 expect resp.status == 200
198 expect resp.http.content-encoding == "<undef>"
199 expect resp.http.etag == "invalid"
200 expect resp.bodylen == 100
201
202 txreq -url "/invalid4" \
203 -hdr "Accept-Encoding: gzip"
204 rxresp
205 expect resp.status == 200
206 expect resp.http.content-encoding == "<undef>"
207 expect resp.http.etag == "W/\"invalid"
208 expect resp.bodylen == 100
209
210 txreq -url "/invalid5" \
211 -hdr "Accept-Encoding: gzip"
212 rxresp
213 expect resp.status == 200
214 expect resp.http.content-encoding == "<undef>"
215 expect resp.http.etag == "W/invalid\""
216 expect resp.bodylen == 100
217
218 txreq -url "/invalid6" \
219 -hdr "Accept-Encoding: gzip"
220 rxresp
221 expect resp.status == 200
222 expect resp.http.content-encoding == "<undef>"
223 expect resp.http.etag == "W/invalid"
224 expect resp.bodylen == 100
225
226 txreq -url "/multiple" \
227 -hdr "Accept-Encoding: gzip"
228 rxresp
229 expect resp.status == 200
230 expect resp.http.content-encoding == "<undef>"
231 expect resp.bodylen == 100
232} -run