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 | 3bc6af4 | 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 | 3bc6af4 | 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 |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 149 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 150 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 151 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 152 | |
| 153 | frontend fe |
| 154 | bind "fd@${fe}" |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 155 | 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] | 156 | default_backend test |
| 157 | |
| 158 | backend test |
| 159 | http-request cache-use my_cache |
| 160 | server www ${s1_addr}:${s1_port} |
| 161 | http-response cache-store my_cache |
| 162 | http-response set-header X-Cache-Hit %[res.cache_hit] |
| 163 | |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 164 | backend no_vary_be |
| 165 | http-request cache-use no_vary_cache |
| 166 | server www ${s2_addr}:${s2_port} |
| 167 | http-response cache-store no_vary_cache |
| 168 | http-response set-header X-Cache-Hit %[res.cache_hit] |
| 169 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 170 | cache my_cache |
| 171 | total-max-size 3 |
| 172 | max-age 20 |
| 173 | max-object-size 3072 |
Remi Tricot-Le Breton | e6cc5b5 | 2020-12-23 18:13:53 +0100 | [diff] [blame] | 174 | process-vary on |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 175 | |
| 176 | cache no_vary_cache |
| 177 | total-max-size 3 |
| 178 | max-age 20 |
| 179 | max-object-size 3072 |
Remi Tricot-Le Breton | e6cc5b5 | 2020-12-23 18:13:53 +0100 | [diff] [blame] | 180 | process-vary off |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 181 | } -start |
| 182 | |
| 183 | |
| 184 | client c1 -connect ${h1_fe_sock} { |
| 185 | # Accept-Encoding Vary |
| 186 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: first_value" |
| 187 | rxresp |
| 188 | expect resp.status == 200 |
Remi Tricot-Le Breton | b054b6d | 2020-12-23 18:13:50 +0100 | [diff] [blame] | 189 | expect resp.http.content-encoding == "gzip" |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 190 | expect resp.bodylen == 45 |
| 191 | |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 192 | # The response for the first request had an unacceptable `content-encoding` |
| 193 | # which might happen if that's the only thing the server supports, but |
| 194 | # we must not cache that and instead defer to the server. |
| 195 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: first_value" |
| 196 | rxresp |
| 197 | expect resp.status == 200 |
| 198 | expect resp.http.content-encoding == "gzip" |
| 199 | expect resp.bodylen == 45 |
| 200 | expect resp.http.X-Cache-Hit == 0 |
| 201 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 202 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: second_value" |
| 203 | rxresp |
| 204 | expect resp.status == 200 |
| 205 | expect resp.bodylen == 48 |
| 206 | expect resp.http.content-type == "text/plain" |
| 207 | expect resp.http.X-Cache-Hit == 0 |
| 208 | |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 209 | # This request matches the cache entry for the request above, despite |
| 210 | # matching the `accept-encoding` of the first request because the |
| 211 | # request above only has the `identity` encoding which is implicitly |
Ilya Shipitsin | 1e9a666 | 2021-01-05 22:10:46 +0500 | [diff] [blame] | 212 | # added, unless explicitly forbidden. |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 213 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: first_value" |
| 214 | rxresp |
| 215 | expect resp.status == 200 |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 216 | expect resp.bodylen == 48 |
| 217 | expect resp.http.content-type == "text/plain" |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 218 | expect resp.http.X-Cache-Hit == 1 |
| 219 | |
| 220 | txreq -url "/accept-encoding" -hdr "Accept-Encoding: second_value" |
| 221 | rxresp |
| 222 | expect resp.status == 200 |
| 223 | expect resp.bodylen == 48 |
| 224 | expect resp.http.content-type == "text/plain" |
| 225 | expect resp.http.X-Cache-Hit == 1 |
| 226 | |
Remi Tricot-Le Breton | 8bb72aa | 2020-11-30 17:06:03 +0100 | [diff] [blame] | 227 | # The accept-encoding normalizer function converts the header values |
| 228 | # to lower case then calculates the hash of every sub part before |
| 229 | # sorting the hashes and xor'ing them (while removing duplicates). |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 230 | txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: first,second" |
| 231 | rxresp |
| 232 | expect resp.status == 200 |
| 233 | expect resp.bodylen == 51 |
| 234 | expect resp.http.X-Cache-Hit == 0 |
| 235 | |
| 236 | txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: first,second" |
| 237 | rxresp |
| 238 | expect resp.status == 200 |
| 239 | expect resp.bodylen == 51 |
| 240 | expect resp.http.X-Cache-Hit == 1 |
| 241 | |
| 242 | txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: second,first" |
| 243 | rxresp |
| 244 | expect resp.status == 200 |
| 245 | expect resp.bodylen == 51 |
| 246 | expect resp.http.X-Cache-Hit == 1 |
| 247 | |
Remi Tricot-Le Breton | 8bb72aa | 2020-11-30 17:06:03 +0100 | [diff] [blame] | 248 | txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: FirsT,SECOND,first" |
| 249 | rxresp |
| 250 | expect resp.status == 200 |
| 251 | expect resp.bodylen == 51 |
| 252 | expect resp.http.X-Cache-Hit == 1 |
| 253 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 254 | # Unmanaged vary |
| 255 | txreq -url "/unmanaged" -hdr "Accept-Encoding: first_value" |
| 256 | rxresp |
| 257 | expect resp.status == 200 |
| 258 | expect resp.bodylen == 51 |
| 259 | expect resp.http.X-Cache-Hit == 0 |
| 260 | |
| 261 | txreq -url "/unmanaged" -hdr "Accept-Encoding: first_value" |
| 262 | rxresp |
| 263 | expect resp.status == 200 |
| 264 | expect resp.bodylen == 51 |
| 265 | expect resp.http.X-Cache-Hit == 0 |
| 266 | |
| 267 | |
| 268 | # Mixed Vary (Accept-Encoding + Referer) |
| 269 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 270 | -hdr "Accept-Encoding: br, gzip" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 271 | -hdr "Referer: referer" |
| 272 | rxresp |
| 273 | expect resp.status == 200 |
| 274 | expect resp.bodylen == 51 |
| 275 | expect resp.http.X-Cache-Hit == 0 |
| 276 | |
| 277 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 278 | -hdr "Accept-Encoding: br" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 279 | -hdr "Referer: other-referer" |
| 280 | rxresp |
| 281 | expect resp.status == 200 |
| 282 | expect resp.bodylen == 54 |
| 283 | expect resp.http.X-Cache-Hit == 0 |
| 284 | |
| 285 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 286 | -hdr "Accept-Encoding: gzip" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 287 | -hdr "Referer: other-referer" |
| 288 | rxresp |
| 289 | expect resp.status == 200 |
| 290 | expect resp.bodylen == 57 |
| 291 | expect resp.http.X-Cache-Hit == 0 |
| 292 | |
| 293 | txreq -url "/referer-accept-encoding" \ |
| 294 | -hdr "Referer: referer" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 295 | -hdr "Accept-Encoding: gzip, br" |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 296 | rxresp |
| 297 | expect resp.status == 200 |
| 298 | expect resp.bodylen == 51 |
| 299 | expect resp.http.X-Cache-Hit == 1 |
| 300 | |
| 301 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 302 | -hdr "Accept-Encoding: br" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 303 | -hdr "Referer: other-referer" |
| 304 | rxresp |
| 305 | expect resp.status == 200 |
| 306 | expect resp.bodylen == 54 |
| 307 | expect resp.http.X-Cache-Hit == 1 |
| 308 | |
| 309 | txreq -url "/referer-accept-encoding" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 310 | -hdr "Accept-Encoding: gzip" \ |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 311 | -hdr "Referer: other-referer" |
| 312 | rxresp |
| 313 | expect resp.status == 200 |
| 314 | expect resp.bodylen == 57 |
| 315 | expect resp.http.X-Cache-Hit == 1 |
Remi Tricot-Le Breton | 754b242 | 2020-11-16 15:56:10 +0100 | [diff] [blame] | 316 | |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 317 | |
| 318 | # Multiple Accept-encoding headers |
| 319 | txreq -url "/multiple_headers" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 320 | -hdr "Accept-Encoding: gzip" \ |
| 321 | -hdr "Accept-Encoding: br, deflate" |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 322 | rxresp |
| 323 | expect resp.status == 200 |
| 324 | expect resp.bodylen == 155 |
| 325 | expect resp.http.X-Cache-Hit == 0 |
| 326 | |
| 327 | txreq -url "/multiple_headers" \ |
Tim Duesterhus | dc38bc4 | 2020-12-29 12:43:53 +0100 | [diff] [blame] | 328 | -hdr "Accept-Encoding: deflate" \ |
| 329 | -hdr "Accept-Encoding: br,gzip" |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 330 | rxresp |
| 331 | expect resp.status == 200 |
| 332 | expect resp.bodylen == 155 |
| 333 | expect resp.http.X-Cache-Hit == 1 |
| 334 | |
| 335 | # Should not match a cache entry |
| 336 | txreq -url "/multiple_headers" \ |
| 337 | -hdr "Accept-Encoding: first_encoding" |
| 338 | rxresp |
| 339 | expect resp.status == 200 |
| 340 | expect resp.bodylen == 166 |
| 341 | expect resp.http.X-Cache-Hit == 0 |
| 342 | |
| 343 | # Too many accept encodings |
| 344 | txreq -url "/too_many_encodings" \ |
| 345 | -hdr "Accept-Encoding: a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17" |
| 346 | rxresp |
| 347 | expect resp.status == 200 |
| 348 | expect resp.bodylen == 177 |
| 349 | expect resp.http.X-Cache-Hit == 0 |
| 350 | |
| 351 | txreq -url "/too_many_encodings" \ |
| 352 | -hdr "Accept-Encoding: a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17" |
| 353 | rxresp |
| 354 | expect resp.status == 200 |
| 355 | expect resp.bodylen == 188 |
| 356 | expect resp.http.X-Cache-Hit == 0 |
| 357 | |
Tim Duesterhus | 3bc6af4 | 2021-06-18 15:09:28 +0200 | [diff] [blame] | 358 | # A missing 'Accept-Encoding' implies that anything is acceptable, |
| 359 | # while an empty 'Accept-Encoding' implies nothing is acceptable. |
| 360 | |
| 361 | # Start by caching a gzip response. |
| 362 | txreq -url "/empty-vs-missing" -hdr "Accept-Encoding: gzip" |
| 363 | rxresp |
| 364 | expect resp.status == 200 |
| 365 | expect resp.bodylen == 234 |
| 366 | expect resp.http.content-encoding == "gzip" |
| 367 | expect resp.http.X-Cache-Hit == 0 |
| 368 | |
| 369 | # Check that it is cached. |
| 370 | txreq -url "/empty-vs-missing" -hdr "Accept-Encoding: gzip" |
| 371 | rxresp |
| 372 | expect resp.status == 200 |
| 373 | expect resp.bodylen == 234 |
| 374 | expect resp.http.content-encoding == "gzip" |
| 375 | expect resp.http.X-Cache-Hit == 1 |
| 376 | |
| 377 | # Check that the cached response is returned when no accept-encoding is |
| 378 | # specified. |
| 379 | txreq -url "/empty-vs-missing" |
| 380 | rxresp |
| 381 | expect resp.status == 200 |
| 382 | expect resp.bodylen == 234 |
| 383 | expect resp.http.content-encoding == "gzip" |
| 384 | expect resp.http.X-Cache-Hit == 1 |
| 385 | |
| 386 | # Check that the cached response is not returned when an empty |
| 387 | # accept-encoding is specified. |
| 388 | txreq -url "/empty-vs-missing" -hdr "Accept-Encoding:" |
| 389 | rxresp |
| 390 | expect resp.status == 200 |
| 391 | expect resp.bodylen == 256 |
| 392 | expect resp.http.content-encoding == "<undef>" |
| 393 | expect resp.http.X-Cache-Hit == 0 |
Remi Tricot-Le Breton | e4421de | 2020-12-23 18:13:46 +0100 | [diff] [blame] | 394 | |
Remi Tricot-Le Breton | 8bb72aa | 2020-11-30 17:06:03 +0100 | [diff] [blame] | 395 | # 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] | 396 | # responses containing a Vary header |
| 397 | txreq -url "/no_vary_support" |
| 398 | rxresp |
| 399 | expect resp.status == 200 |
| 400 | expect resp.bodylen == 57 |
| 401 | expect resp.http.X-Cache-Hit == 0 |
| 402 | |
| 403 | txreq -url "/no_vary_support" |
| 404 | rxresp |
| 405 | expect resp.status == 200 |
| 406 | expect resp.bodylen == 57 |
| 407 | expect resp.http.X-Cache-Hit == 0 |
| 408 | |
| 409 | |
Remi Tricot-Le Breton | 1785f3d | 2020-11-16 15:56:09 +0100 | [diff] [blame] | 410 | } -run |