Commit 30d8a8c7 authored by Geoff Simmons's avatar Geoff Simmons

Fix the junk-after-gunzip test for Varnish versions up to 6.3.0.

Also add a test to demonstrate that the error can happen with serial
ESI, so the problem does not depend on pESI, and is not caused by
the VDP.

The moral of the story: don't set beresp.filters without testgunzip
when the beresp is gzipped, or just let varinshd set the default
VFP stack.
parent 87f689a1
varnishtest "VDP gunzip for an include, when there is junk after gzip"
# cf. junk-after-gunzip.vtc in src/tests. This is to demonstrate that
# the endless loop for the junk-after-gunzip error, fixed in Varnish
# #3109, is present in versions up to 6.3.0, and can be encountered
# with serial ESI. So it is not unique to pESI or caused by the
# VDP. The error is avoided by setting beresp.filters properly, or by
# not setting it, allowing varnishd to set up the default VFP stack,
# as explained below.
server s1 {
rxreq
txresp -body {<Before esi>
<esi:include src="/junk.html"/>
After esi
}
} -start
server s2 {
rxreq
expect req.url == "/junk.html"
txresp -hdr "content-encoding: gzip" -nolen
# cf Varnish r03109.vtc
sendhex "1f 8b 08 00 f5 8a b9 5d 02 03 0b 4f 4d 51 30 36"
sendhex "50 f0 4f 2e 51 30 34 b1 32 30 b7 32 30 54 70 76"
sendhex "0d 51 30 32 30 b4 e4 02 00 fa 76 79 ba 1d 00 00"
sendhex "00 62 61 64 0a"
} -start
varnish v1 -vcl+backend {
sub vcl_backend_fetch {
if (bereq.url == "/") {
set bereq.backend = s1;
}
else {
set bereq.backend = s2;
}
}
sub vcl_backend_response {
# At the ESI level at which the beresp is gzipped, we
# set beresp.filters to "". If beresp.filters is not
# set in VCL, then varnishd sets a default VFP stack,
# which in this case includes testgunzip. testgunzip
# detects the error, so the beresp.body is empty and
# not gzipped. This is how VDP gunzip ordinarily
# avoids the error.
if (bereq.url == "/") {
set beresp.do_esi = true;
}
else {
set beresp.filters = "";
}
}
sub vcl_deliver {
# The gunzip VDP runs into the endless loop, for Varnish
# versions up to 6.3.0, if the testgunzip VFP was not run.
if (req.esi_level == 1) {
set resp.filters = "gunzip";
}
}
} -start
client c1 {
txreq
rxresp
} -run
......@@ -32,12 +32,24 @@ varnish v1 -vcl+backend {
}
sub vcl_backend_response {
# The bug fixed in Varnish #3109 is present in versions up
# to 6.3.0, and would be brought about if beresp.filters
# is empty in the ESI level at which the backend response
# is gzipped, as in the commented-out else clause below.
# If beresp.filters is not set in VCL, then the default
# VFP stack set by varnishd includes testgunzip, which
# detects the error. Then the response body seen by
# delivery is empty and not gzipped, so VDP gunzip does
# not encounter the error. The moral being don't set
# beresp.filters without testgunzip in such a situation,
# or just allow varnishd to set the default VFP stack.
if (bereq.url == "/") {
set beresp.do_esi = true;
}
else {
set beresp.filters = "";
}
# else {
# set beresp.filters = "";
# }
}
sub vcl_deliver {
......
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