Commit d464fbd8 authored by Geoff Simmons's avatar Geoff Simmons

Add a test to verify that a 304 beresp does not change Content-Encoding.

See the discussion in Varnish issue #2910. A 304 IMS beresp could
(weirdly) set Content-Encoding to something other than the result
of previous VFP filtering, in this case compressing the response
with gzip. Nevertheless, Varnish does the right thing when the
OF_CHGGZIP flag is set.
parent 9fbc3560
......@@ -89,3 +89,66 @@ client c1 {
expect resp.bodylen == 43
expect resp.body == "The quick brown fox jumps over the lazy dog"
} -run
# A beresp is first gzipped by Varnish, then the backend sends an IMS
# response claiming that the validated object is br-encoded. The following
# is to verify that Varnish does the right thing.
server s1 -wait
server s1 {
rxreq
txresp -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" \
-hdr {ETag: "foo"} \
-body {The quick brown fox jumps over the lazy dog}
rxreq
expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT"
txresp -status 304 \
-hdr {ETag: "bar"} -hdr "Content-Encoding: br" \
-nolen
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.http.foobar = beresp.http.content-encoding;
set beresp.do_gzip = true;
set beresp.ttl = 0.5s;
set beresp.grace = 0s;
set beresp.keep = 60s;
}
}
client c1 {
txreq -hdr "Accept-Encoding: gzip"
rxresp
expect resp.http.content-encoding == "gzip"
expect resp.http.foobar == ""
expect resp.http.etag == {W/"foo"}
gunzip
expect resp.body == "The quick brown fox jumps over the lazy dog"
} -run
delay 0.6
# Although br compression is specified here, it is bypassed for the
# 304 backend response.
varnish v1 -vcl+backend {
import ${vmod_brotli};
sub vcl_backend_response {
set beresp.http.foobar = beresp.http.content-encoding;
set beresp.filters = "br";
}
}
# A client that does not send Accept-Encoding gets the decompressed
# object, with no Content-Encoding header. Header foobar shows the
# Content-Encoding header as saved in the cached object, which is
# still "gzip".
client c1 {
txreq
rxresp
expect resp.http.content-encoding == <undef>
expect resp.http.foobar == "gzip"
expect resp.http.etag == {W/"bar"}
expect resp.body == "The quick brown fox jumps over the lazy dog"
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment