[master] d2be2bfc0 Look at Content-Encoding to determine gzip status for esi subrequests
Nils Goroll
nils.goroll at uplex.de
Sat Feb 20 15:00:10 UTC 2021
commit d2be2bfc0f59ef79cd8efa4720ace4e49e55dcb6
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Sat Feb 20 15:51:49 2021 +0100
Look at Content-Encoding to determine gzip status for esi subrequests
to handle correctly use of the "gunzip" filter at esi_level > 0
Fixes #3529
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 68ae73268..082e32631 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -844,7 +844,8 @@ static const struct vdp ved_ved = {
static void v_matchproto_(vtr_deliver_f)
ved_deliver(struct req *req, struct boc *boc, int wantbody)
{
- int i;
+ int i = 0;
+ const char *p;
struct ecx *ecx;
struct ved_foo foo[1];
@@ -860,7 +861,11 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
if (boc == NULL && ObjGetLen(req->wrk, req->objcore) == 0)
return;
- i = ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED);
+ if (http_GetHdr(req->resp, H_Content_Encoding, &p))
+ i = !strcasecmp(p, "gzip");
+ if (i)
+ i = ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED);
+
if (ecx->isgzip && i && !(req->res_mode & RES_ESI)) {
/* A gzip'ed include which is not ESI processed */
diff --git a/bin/varnishtest/tests/e00026.vtc b/bin/varnishtest/tests/e00026.vtc
index 2e5c06ffd..7fa85d0cf 100644
--- a/bin/varnishtest/tests/e00026.vtc
+++ b/bin/varnishtest/tests/e00026.vtc
@@ -25,13 +25,30 @@ server s1 {
expect req.http.accept-encoding == gzip
txresp -gzipbody {<esi:include src="/foo"/>}
+ rxreq
+ expect req.url == "/5"
+ expect req.http.accept-encoding == gzip
+ txresp -gzipbody {<esi:include src="/bar"/>}
+
+ rxreq
+ expect req.url == "/bar"
+ txresp -bodylen 500
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
- if (bereq.url != "/foo") {
+ if (bereq.url ~ "^/.$") {
set beresp.do_esi = true;
+ } else
+ if (bereq.url ~ "/bar") {
+ set beresp.do_gzip = true;
+ }
+ }
+ sub vcl_deliver {
+ if (req.esi_level > 0 && req.http.r3529) {
+ unset req.http.Accept-Encoding;
}
+ set resp.http.filters = resp.filters;
}
} -start
@@ -74,6 +91,12 @@ client c1 {
expect resp.status == 200
expect resp.bodylen == 13
+ txreq -url /5 -hdr "Accept-Encoding: gzip" -hdr "r3529: 1"
+ rxresp
+ expect resp.http.content-encoding == gzip
+ gunzip
+ expect resp.status == 200
+ expect resp.bodylen == 500
}
client c1 -run
More information about the varnish-commit
mailing list