Find attached proposed fix for #980.

Regards,
Martin

-- 
Martin Blix Grydeland
Varnish Software AS
commit 0f7bd817464321f7d3af1a19a34970891cef2fa8
Author: Martin Blix Grydeland <[email protected]>
Date:   Wed Aug 17 01:16:28 2011 +0200

    Do not attempt to do content-length transfer when streaming if do_zip is true
    
    Fixes: #980

diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 4a9e63a..25e2be8 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -167,7 +167,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))
+	    (sp->wrk->h_content_length != NULL &&
+	     !sp->wrk->do_gunzip && !sp->wrk->do_gzip))
 		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
_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to