[master] 298c7c3 We can not use a lenght based response when we transform (gzip/gunzip) we stream and backend didn't send c-l.

Poul-Henning Kamp phk at varnish-cache.org
Wed Aug 17 09:10:07 CEST 2011


commit 298c7c382b731dbde290ce32d3199d076a4d845d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Aug 17 07:08:11 2011 +0000

    We can not use a lenght based response when
    	we transform (gzip/gunzip)
    	we stream and backend didn't send c-l.
    
    Fixes	#980
    
    Testcase by:	Martin

diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 42d4b3b..672e1dc 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -166,8 +166,8 @@ cnt_prepresp(struct sess *sp)
 
 	sp->wrk->res_mode = 0;
 
-	if (!sp->wrk->do_stream ||
-	    (sp->wrk->h_content_length != NULL && !sp->wrk->do_gunzip))
+	if ((sp->wrk->h_content_length != NULL || !sp->wrk->do_stream) &&
+	    !sp->wrk->do_gzip && !sp->wrk->do_gunzip)
 		sp->wrk->res_mode |= RES_LEN;
 
 	if (!sp->disable_esi && sp->obj->esidata != NULL) {
diff --git a/bin/varnishtest/tests/r00980.vtc b/bin/varnishtest/tests/r00980.vtc
new file mode 100644
index 0000000..9591786
--- /dev/null
+++ b/bin/varnishtest/tests/r00980.vtc
@@ -0,0 +1,29 @@
+varnishtest "r00980 test gzip on fetch with content_length and do_stream"
+
+server s1 {
+	rxreq
+	expect req.url == "/foobar"
+	expect req.http.accept-encoding == "gzip"
+	txresp -bodylen 43
+} -start
+
+varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend {
+
+	sub vcl_fetch {
+		set beresp.do_gzip = true;
+		set beresp.do_stream = true;
+	}
+} -start
+
+client c1 {
+	txreq -url /foobar -hdr "Accept-Encoding: gzip"
+	rxresp
+	expect resp.http.content-encoding == "gzip"
+	gunzip
+	expect resp.bodylen == 43
+
+	txreq -url /foobar 
+	rxresp
+	expect resp.http.content-encoding == "resp.http.content-encoding"
+	expect resp.bodylen == 43
+} -run



More information about the varnish-commit mailing list