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
parent e89cd5f6
......@@ -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 */
......
......@@ -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
......
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