blob: 0cae679592756318ca455ce7b2f1f1e744b86282 [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 {
109 defaults
110 mode http
111 ${no-htx} option http-use-htx
112 timeout connect 1s
113 timeout client 1s
114 timeout server 1s
115
116 frontend fe-gzip
117 bind "fd@${fe_gzip}"
118 default_backend be-gzip
119
120 backend be-gzip
121 compression algo gzip
122 compression type text/html text/plain
123 server www ${s1_addr}:${s1_port}
124} -start
125
126client c1 -connect ${h1_fe_gzip_sock} {
127 txreq -url "/strong" \
128 -hdr "Accept-Encoding: gzip"
129 rxresp
130 expect resp.status == 200
131 expect resp.http.content-encoding == "gzip"
132 expect resp.http.etag == "W/\"123\""
133 gunzip
134 expect resp.bodylen == 100
135
136 txreq -url "/weak" \
137 -hdr "Accept-Encoding: gzip"
138 rxresp
139 expect resp.status == 200
140 expect resp.http.content-encoding == "gzip"
141 expect resp.http.etag == "W/\"456\""
142 gunzip
143 expect resp.bodylen == 100
144
145 txreq -url "/weak-incorrect-quoting" \
146 -hdr "Accept-Encoding: gzip"
147 rxresp
148 expect resp.status == 200
149 expect resp.http.content-encoding == "gzip"
150 expect resp.http.etag == "W/\"W/789\""
151 gunzip
152 expect resp.bodylen == 100
153
154 txreq -url "/empty-strong" \
155 -hdr "Accept-Encoding: gzip"
156 rxresp
157 expect resp.status == 200
158 expect resp.http.content-encoding == "gzip"
159 expect resp.http.etag == "W/\"\""
160 gunzip
161 expect resp.bodylen == 100
162
163 txreq -url "/empty-weak" \
164 -hdr "Accept-Encoding: gzip"
165 rxresp
166 expect resp.status == 200
167 expect resp.http.content-encoding == "gzip"
168 expect resp.http.etag == "W/\"\""
169 gunzip
170 expect resp.bodylen == 100
171
172 txreq -url "/invalid1" \
173 -hdr "Accept-Encoding: gzip"
174 rxresp
175 expect resp.status == 200
176 expect resp.http.content-encoding == "<undef>"
177 expect resp.http.etag == "\"invalid"
178 expect resp.bodylen == 100
179
180 txreq -url "/invalid2" \
181 -hdr "Accept-Encoding: gzip"
182 rxresp
183 expect resp.status == 200
184 expect resp.http.content-encoding == "<undef>"
185 expect resp.http.etag == "invalid\""
186 expect resp.bodylen == 100
187
188 txreq -url "/invalid3" \
189 -hdr "Accept-Encoding: gzip"
190 rxresp
191 expect resp.status == 200
192 expect resp.http.content-encoding == "<undef>"
193 expect resp.http.etag == "invalid"
194 expect resp.bodylen == 100
195
196 txreq -url "/invalid4" \
197 -hdr "Accept-Encoding: gzip"
198 rxresp
199 expect resp.status == 200
200 expect resp.http.content-encoding == "<undef>"
201 expect resp.http.etag == "W/\"invalid"
202 expect resp.bodylen == 100
203
204 txreq -url "/invalid5" \
205 -hdr "Accept-Encoding: gzip"
206 rxresp
207 expect resp.status == 200
208 expect resp.http.content-encoding == "<undef>"
209 expect resp.http.etag == "W/invalid\""
210 expect resp.bodylen == 100
211
212 txreq -url "/invalid6" \
213 -hdr "Accept-Encoding: gzip"
214 rxresp
215 expect resp.status == 200
216 expect resp.http.content-encoding == "<undef>"
217 expect resp.http.etag == "W/invalid"
218 expect resp.bodylen == 100
219
220 txreq -url "/multiple" \
221 -hdr "Accept-Encoding: gzip"
222 rxresp
223 expect resp.status == 200
224 expect resp.http.content-encoding == "<undef>"
225 expect resp.bodylen == 100
226} -run