Commit a61cf0d1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

NUL terminate the ungzip'ed body so we can expect on it.

Fixes #1688
parent 6bd3d3ba
varnishtest "ESI-included, compressed synthetic responses"
server s1 {
rxreq
expect req.url == "/bar"
txresp -gzipbody {<XYZ><esi:include src="/foo"/></XYZ>}
rxreq
expect req.url == "/baz"
txresp -gzipbody {<XYZ><esi:include src="/quux"/></XYZ>}
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
if (req.url == "/foo" || req.url == "/quux") {
return(synth(998, "included synthetic reponse"));
}
}
sub vcl_synth {
if (resp.status == 998) {
synthetic("this is the body of an included synthetic response");
return(deliver);
}
}
sub vcl_backend_response {
set beresp.do_esi = true;
}
} -start
client c1 {
txreq -url /bar
rxresp
expect resp.status == 200
delay .1
expect resp.body == "<XYZ>this is the body of an included synthetic response</XYZ>"
txreq -url /baz -hdr "Accept-Encoding: gzip"
timeout 2
rxresp
expect resp.status == 200
expect resp.http.Content-Encoding == "gzip"
gunzip
expect resp.body == "<XYZ>this is the body of an included synthetic response</XYZ>"
} -run
......@@ -633,6 +633,7 @@ cmd_http_gunzip_body(CMD_ARGS)
assert(Z_OK == inflateInit2(&vz, 31));
i = inflate(&vz, Z_FINISH);
assert(vz.total_out < l);
hp->bodyl = vz.total_out;
memcpy(hp->body, p, hp->bodyl);
free(p);
......@@ -653,6 +654,7 @@ cmd_http_gunzip_body(CMD_ARGS)
"Gunzip error = %d (%s) in:%jd out:%jd",
i, vz.msg, (intmax_t)vz.total_in, (intmax_t)vz.total_out);
assert(Z_OK == inflateEnd(&vz));
hp->body[hp->bodyl] = '\0';
}
/**********************************************************************
......
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