[master] a61cf0d NUL terminate the ungzip'ed body so we can expect on it.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Mar 2 15:07:18 CET 2015
commit a61cf0d1a693add65432d8a796a6630af0df5956
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Mar 2 14:06:48 2015 +0000
NUL terminate the ungzip'ed body so we can expect on it.
Fixes #1688
diff --git a/bin/varnishtest/tests/r01688.vtc b/bin/varnishtest/tests/r01688.vtc
new file mode 100644
index 0000000..fd0373b
--- /dev/null
+++ b/bin/varnishtest/tests/r01688.vtc
@@ -0,0 +1,45 @@
+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
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index ba591ae..68aacde 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -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';
}
/**********************************************************************
More information about the varnish-commit
mailing list