Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 1 | varnishtest "Vary support" |
| 2 | |
Christopher Faulet | 85a8136 | 2020-12-15 17:13:39 +0100 | [diff] [blame] | 3 | #REQUIRE_VERSION=2.4 |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 4 | |
| 5 | feature ignore_unknown_macro |
| 6 | |
| 7 | server s1 { |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 8 | # Response varying on "accept-encoding" with |
| 9 | # an unacceptable content-encoding |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 10 | rxreq |
| 11 | expect req.url == "/accept-encoding" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 12 | txresp -hdr "Content-Encoding: gzip" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 13 | -hdr "Vary: accept-encoding" \ |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 14 | -hdr "Cache-Control: max-age=5" \ |
| 15 | -bodylen 45 |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 16 | |
| 17 | # Response varying on "accept-encoding" |
| 18 | rxreq |
| 19 | expect req.url == "/accept-encoding" |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 20 | txresp -hdr "Content-Encoding: gzip" \ |
| 21 | -hdr "Vary: accept-encoding" \ |
| 22 | -hdr "Cache-Control: max-age=5" \ |
| 23 | -bodylen 45 |
| 24 | |
| 25 | # Response varying on "accept-encoding" with |
| 26 | # no content-encoding |
| 27 | rxreq |
| 28 | expect req.url == "/accept-encoding" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 29 | txresp -hdr "Content-Type: text/plain" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 30 | -hdr "Vary: accept-encoding" \ |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 31 | -hdr "Cache-Control: max-age=5" \ |
| 32 | -bodylen 48 |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 33 | |
| 34 | # Response varying on "accept-encoding" but having two different encodings |
| 35 | rxreq |
| 36 | expect req.url == "/accept-encoding-multiple" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 37 | txresp -hdr "Vary: accept-encoding" \ |
| 38 | -hdr "Cache-Control: max-age=5" \ |
| 39 | -bodylen 51 |
| 40 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 41 | |
| 42 | # Unmanaged vary |
| 43 | rxreq |
| 44 | expect req.url == "/unmanaged" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 45 | txresp -hdr "Vary: accept-encoding,unmanaged" \ |
| 46 | -hdr "Cache-Control: max-age=5" \ |
| 47 | -bodylen 51 |
| 48 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 49 | |
| 50 | rxreq |
| 51 | expect req.url == "/unmanaged" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 52 | txresp -hdr "Vary: accept-encoding,unmanaged" \ |
| 53 | -hdr "Cache-Control: max-age=5" \ |
| 54 | -bodylen 51 |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 55 | |
| 56 | |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 57 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 58 | # Mixed Vary (Accept-Encoding + Referer) |
| 59 | rxreq |
| 60 | expect req.url == "/referer-accept-encoding" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 61 | txresp -hdr "Vary: accept-encoding,referer" \ |
| 62 | -hdr "Cache-Control: max-age=5" \ |
| 63 | -hdr "Content-Encoding: gzip" \ |
| 64 | -bodylen 51 |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 65 | |
| 66 | rxreq |
| 67 | expect req.url == "/referer-accept-encoding" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 68 | txresp -hdr "Vary: referer,accept-encoding" \ |
| 69 | -hdr "Cache-Control: max-age=5" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 70 | -hdr "Content-Encoding: br" \ |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 71 | -bodylen 54 |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 72 | |
| 73 | rxreq |
| 74 | expect req.url == "/referer-accept-encoding" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 75 | txresp -hdr "Vary: referer,accept-encoding" \ |
| 76 | -hdr "Cache-Control: max-age=5" \ |
| 77 | -hdr "Content-Encoding: gzip" \ |
| 78 | -bodylen 57 |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 79 | |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 80 | # Multiple Accept-Encoding headers |
| 81 | rxreq |
| 82 | expect req.url == "/multiple_headers" |
| 83 | txresp -hdr "Vary: accept-encoding" \ |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 84 | -hdr "Cache-Control: max-age=5" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 85 | -hdr "Content-Encoding: br" \ |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 86 | -bodylen 155 |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 87 | |
| 88 | rxreq |
| 89 | expect req.url == "/multiple_headers" |
| 90 | txresp -hdr "Vary: accept-encoding" \ |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 91 | -hdr "Cache-Control: max-age=5" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 92 | -hdr "Content-Encoding: br" \ |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 93 | -bodylen 166 |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 94 | |
| 95 | |
| 96 | # Too many Accept-Encoding values (we will not cache responses with more than 16 encodings) |
| 97 | rxreq |
| 98 | expect req.url == "/too_many_encodings" |
| 99 | txresp -hdr "Vary: accept-encoding" \ |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 100 | -hdr "Cache-Control: max-age=5" \ |
| 101 | -hdr "Content-Encoding: gzip" \ |
| 102 | -bodylen 177 |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 103 | |
| 104 | rxreq |
| 105 | expect req.url == "/too_many_encodings" |
| 106 | txresp -hdr "Vary: accept-encoding" \ |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 107 | -hdr "Cache-Control: max-age=5" \ |
| 108 | -hdr "Content-Encoding: gzip" \ |
| 109 | -bodylen 188 |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 110 | |
Tim Duesterhus | beec7ea | 2021-06-18 15:09:28 +0200 | [diff] [blame] | 111 | rxreq |
| 112 | expect req.url == "/empty-vs-missing" |
| 113 | txresp -hdr "Content-Encoding: gzip" \ |
| 114 | -hdr "Vary: accept-encoding" \ |
| 115 | -hdr "Cache-Control: max-age=5" \ |
| 116 | -bodylen 234 |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 117 | |
Tim Duesterhus | beec7ea | 2021-06-18 15:09:28 +0200 | [diff] [blame] | 118 | rxreq |
| 119 | expect req.url == "/empty-vs-missing" |
| 120 | txresp -hdr "Vary: accept-encoding" \ |
| 121 | -hdr "Cache-Control: max-age=5" \ |
| 122 | -bodylen 256 |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 123 | } -start |
| 124 | |
| 125 | server s2 { |
| 126 | # Responses that should not be cached |
| 127 | rxreq |
| 128 | expect req.url == "/no_vary_support" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 129 | txresp -hdr "Vary: accept-encoding" \ |
| 130 | -hdr "Cache-Control: max-age=5" \ |
| 131 | -bodylen 57 |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 132 | |
| 133 | rxreq |
| 134 | expect req.url == "/no_vary_support" |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 135 | txresp -hdr "Vary: accept-encoding" \ |
| 136 | -hdr "Cache-Control: max-age=5" \ |
| 137 | -bodylen 57 |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 138 | } -start |
| 139 | |
| 140 | haproxy h1 -conf { |
Willy Tarreau | e1465c1 | 2021-05-09 14:41:41 +0200 | [diff] [blame] | 141 | global |
| 142 | # WT: limit false-positives causing "HTTP header incomplete" due to |
| 143 | # idle server connections being randomly used and randomly expiring |
| 144 | # under us. |
| 145 | tune.idle-pool.shared off |
| 146 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 147 | defaults |
| 148 | mode http |
| 149 | ${no-htx} option http-use-htx |
| 150 | timeout connect 1s |
| 151 | timeout client 1s |
| 152 | timeout server 1s |
| 153 | |
| 154 | frontend fe |
| 155 | bind "fd@${fe}" |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 156 | use_backend no_vary_be if { path_beg /no_vary_support } |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 157 | default_backend test |
| 158 | |
| 159 | backend test |
| 160 | http-request cache-use my_cache |
| 161 | server www ${s1_addr}:${s1_port} |
| 162 | http-response cache-store my_cache |
| 163 | http-response set-header X-Cache-Hit %[res.cache_hit] |
| 164 | |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 165 | backend no_vary_be |
| 166 | http-request cache-use no_vary_cache |
| 167 | server www ${s2_addr}:${s2_port} |
| 168 | http-response cache-store no_vary_cache |
| 169 | http-response set-header X-Cache-Hit %[res.cache_hit] |
| 170 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 171 | cache my_cache |
| 172 | total-max-size 3 |
| 173 | max-age 20 |
| 174 | max-object-size 3072 |
Remi Tricot-Le Breton | e6cc5b5 | 2020-12-23 18:13:53 +0100 | [diff] [blame] | 175 | process-vary on |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 176 | |
| 177 | cache no_vary_cache |
| 178 | total-max-size 3 |
| 179 | max-age 20 |
| 180 | max-object-size 3072 |
Remi Tricot-Le Breton | e6cc5b5 | 2020-12-23 18:13:53 +0100 | [diff] [blame] | 181 | process-vary off |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 182 | } -start |
| 183 | |
| 184 | |
| 185 | client c1 -connect ${h1_fe_sock} { |
| 186 | # Accept-Encoding Vary |
| 187 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: first_value" |
| 188 | rxresp |
| 189 | expect resp.status == 200 |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 190 | expect resp.http.content-encoding == "gzip" |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 191 | expect resp.bodylen == 45 |
| 192 | |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 193 | # The response for the first request had an unacceptable `content-encoding` |
| 194 | # which might happen if that's the only thing the server supports, but |
| 195 | # we must not cache that and instead defer to the server. |
| 196 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: first_value" |
| 197 | rxresp |
| 198 | expect resp.status == 200 |
| 199 | expect resp.http.content-encoding == "gzip" |
| 200 | expect resp.bodylen == 45 |
| 201 | expect resp.http.X-Cache-Hit == 0 |
| 202 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 203 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: second_value" |
| 204 | rxresp |
| 205 | expect resp.status == 200 |
| 206 | expect resp.bodylen == 48 |
| 207 | expect resp.http.content-type == "text/plain" |
| 208 | expect resp.http.X-Cache-Hit == 0 |
| 209 | |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 210 | # This request matches the cache entry for the request above, despite |
| 211 | # matching the `accept-encoding` of the first request because the |
| 212 | # request above only has the `identity` encoding which is implicitly |
Ilya Shipitsin | 1e9a666 | 2021-01-05 22:10:46 +0500 | [diff] [blame] | 213 | # added, unless explicitly forbidden. |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 214 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: first_value" |
| 215 | rxresp |
| 216 | expect resp.status == 200 |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 217 | expect resp.bodylen == 48 |
| 218 | expect resp.http.content-type == "text/plain" |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 219 | expect resp.http.X-Cache-Hit == 1 |
| 220 | |
| 221 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: second_value" |
| 222 | rxresp |
| 223 | expect resp.status == 200 |
| 224 | expect resp.bodylen == 48 |
| 225 | expect resp.http.content-type == "text/plain" |
| 226 | expect resp.http.X-Cache-Hit == 1 |
| 227 | |
Remi Tricot-Le Breton | 8bb72aa | 2020-11-30 17:06:03 +0100 | [diff] [blame] | 228 | # The accept-encoding normalizer function converts the header values |
| 229 | # to lower case then calculates the hash of every sub part before |
| 230 | # sorting the hashes and xor'ing them (while removing duplicates). |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 231 | txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: first,second" |
| 232 | rxresp |
| 233 | expect resp.status == 200 |
| 234 | expect resp.bodylen == 51 |
| 235 | expect resp.http.X-Cache-Hit == 0 |
| 236 | |
| 237 | txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: first,second" |
| 238 | rxresp |
| 239 | expect resp.status == 200 |
| 240 | expect resp.bodylen == 51 |
| 241 | expect resp.http.X-Cache-Hit == 1 |
| 242 | |
| 243 | txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: second,first" |
| 244 | rxresp |
| 245 | expect resp.status == 200 |
| 246 | expect resp.bodylen == 51 |
| 247 | expect resp.http.X-Cache-Hit == 1 |
| 248 | |
Remi Tricot-Le Breton | 8bb72aa | 2020-11-30 17:06:03 +0100 | [diff] [blame] | 249 | txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: FirsT,SECOND,first" |
| 250 | rxresp |
| 251 | expect resp.status == 200 |
| 252 | expect resp.bodylen == 51 |
| 253 | expect resp.http.X-Cache-Hit == 1 |
| 254 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 255 | # Unmanaged vary |
| 256 | txreq -url "/unmanaged" -hdr "Accept-Encoding: first_value" |
| 257 | rxresp |
| 258 | expect resp.status == 200 |
| 259 | expect resp.bodylen == 51 |
| 260 | expect resp.http.X-Cache-Hit == 0 |
| 261 | |
| 262 | txreq -url "/unmanaged" -hdr "Accept-Encoding: first_value" |
| 263 | rxresp |
| 264 | expect resp.status == 200 |
| 265 | expect resp.bodylen == 51 |
| 266 | expect resp.http.X-Cache-Hit == 0 |
| 267 | |
| 268 | |
| 269 | # Mixed Vary (Accept-Encoding + Referer) |
| 270 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 271 | -hdr "Accept-Encoding: br, gzip" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 272 | -hdr "Referer: referer" |
| 273 | rxresp |
| 274 | expect resp.status == 200 |
| 275 | expect resp.bodylen == 51 |
| 276 | expect resp.http.X-Cache-Hit == 0 |
| 277 | |
| 278 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 279 | -hdr "Accept-Encoding: br" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 280 | -hdr "Referer: other-referer" |
| 281 | rxresp |
| 282 | expect resp.status == 200 |
| 283 | expect resp.bodylen == 54 |
| 284 | expect resp.http.X-Cache-Hit == 0 |
| 285 | |
| 286 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 287 | -hdr "Accept-Encoding: gzip" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 288 | -hdr "Referer: other-referer" |
| 289 | rxresp |
| 290 | expect resp.status == 200 |
| 291 | expect resp.bodylen == 57 |
| 292 | expect resp.http.X-Cache-Hit == 0 |
| 293 | |
| 294 | txreq -url "/referer-accept-encoding" \ |
| 295 | -hdr "Referer: referer" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 296 | -hdr "Accept-Encoding: gzip, br" |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 297 | rxresp |
| 298 | expect resp.status == 200 |
| 299 | expect resp.bodylen == 51 |
| 300 | expect resp.http.X-Cache-Hit == 1 |
| 301 | |
| 302 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 303 | -hdr "Accept-Encoding: br" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 304 | -hdr "Referer: other-referer" |
| 305 | rxresp |
| 306 | expect resp.status == 200 |
| 307 | expect resp.bodylen == 54 |
| 308 | expect resp.http.X-Cache-Hit == 1 |
| 309 | |
| 310 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 311 | -hdr "Accept-Encoding: gzip" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 312 | -hdr "Referer: other-referer" |
| 313 | rxresp |
| 314 | expect resp.status == 200 |
| 315 | expect resp.bodylen == 57 |
| 316 | expect resp.http.X-Cache-Hit == 1 |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 317 | |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 318 | |
| 319 | # Multiple Accept-encoding headers |
| 320 | txreq -url "/multiple_headers" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 321 | -hdr "Accept-Encoding: gzip" \ |
| 322 | -hdr "Accept-Encoding: br, deflate" |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 323 | rxresp |
| 324 | expect resp.status == 200 |
| 325 | expect resp.bodylen == 155 |
| 326 | expect resp.http.X-Cache-Hit == 0 |
| 327 | |
| 328 | txreq -url "/multiple_headers" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 329 | -hdr "Accept-Encoding: deflate" \ |
| 330 | -hdr "Accept-Encoding: br,gzip" |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 331 | rxresp |
| 332 | expect resp.status == 200 |
| 333 | expect resp.bodylen == 155 |
| 334 | expect resp.http.X-Cache-Hit == 1 |
| 335 | |
| 336 | # Should not match a cache entry |
| 337 | txreq -url "/multiple_headers" \ |
| 338 | -hdr "Accept-Encoding: first_encoding" |
| 339 | rxresp |
| 340 | expect resp.status == 200 |
| 341 | expect resp.bodylen == 166 |
| 342 | expect resp.http.X-Cache-Hit == 0 |
| 343 | |
| 344 | # Too many accept encodings |
| 345 | txreq -url "/too_many_encodings" \ |
| 346 | -hdr "Accept-Encoding: a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17" |
| 347 | rxresp |
| 348 | expect resp.status == 200 |
| 349 | expect resp.bodylen == 177 |
| 350 | expect resp.http.X-Cache-Hit == 0 |
| 351 | |
| 352 | txreq -url "/too_many_encodings" \ |
| 353 | -hdr "Accept-Encoding: a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17" |
| 354 | rxresp |
| 355 | expect resp.status == 200 |
| 356 | expect resp.bodylen == 188 |
| 357 | expect resp.http.X-Cache-Hit == 0 |
| 358 | |
Tim Duesterhus | beec7ea | 2021-06-18 15:09:28 +0200 | [diff] [blame] | 359 | # A missing 'Accept-Encoding' implies that anything is acceptable, |
| 360 | # while an empty 'Accept-Encoding' implies nothing is acceptable. |
| 361 | |
| 362 | # Start by caching a gzip response. |
| 363 | txreq -url "/empty-vs-missing" -hdr "Accept-Encoding: gzip" |
| 364 | rxresp |
| 365 | expect resp.status == 200 |
| 366 | expect resp.bodylen == 234 |
| 367 | expect resp.http.content-encoding == "gzip" |
| 368 | expect resp.http.X-Cache-Hit == 0 |
| 369 | |
| 370 | # Check that it is cached. |
| 371 | txreq -url "/empty-vs-missing" -hdr "Accept-Encoding: gzip" |
| 372 | rxresp |
| 373 | expect resp.status == 200 |
| 374 | expect resp.bodylen == 234 |
| 375 | expect resp.http.content-encoding == "gzip" |
| 376 | expect resp.http.X-Cache-Hit == 1 |
| 377 | |
| 378 | # Check that the cached response is returned when no accept-encoding is |
| 379 | # specified. |
| 380 | txreq -url "/empty-vs-missing" |
| 381 | rxresp |
| 382 | expect resp.status == 200 |
| 383 | expect resp.bodylen == 234 |
| 384 | expect resp.http.content-encoding == "gzip" |
| 385 | expect resp.http.X-Cache-Hit == 1 |
| 386 | |
| 387 | # Check that the cached response is not returned when an empty |
| 388 | # accept-encoding is specified. |
| 389 | txreq -url "/empty-vs-missing" -hdr "Accept-Encoding:" |
| 390 | rxresp |
| 391 | expect resp.status == 200 |
| 392 | expect resp.bodylen == 256 |
| 393 | expect resp.http.content-encoding == "<undef>" |
| 394 | expect resp.http.X-Cache-Hit == 0 |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 395 | |
Remi Tricot-Le Breton | 8bb72aa | 2020-11-30 17:06:03 +0100 | [diff] [blame] | 396 | # The following requests are treated by a backend that does not cache |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 397 | # responses containing a Vary header |
| 398 | txreq -url "/no_vary_support" |
| 399 | rxresp |
| 400 | expect resp.status == 200 |
| 401 | expect resp.bodylen == 57 |
| 402 | expect resp.http.X-Cache-Hit == 0 |
| 403 | |
| 404 | txreq -url "/no_vary_support" |
| 405 | rxresp |
| 406 | expect resp.status == 200 |
| 407 | expect resp.bodylen == 57 |
| 408 | expect resp.http.X-Cache-Hit == 0 |
| 409 | |
| 410 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 411 | } -run |