[master] 54fe085 Also neuter do_gzip and do_gunzip if content length is zero

Poul-Henning Kamp phk at FreeBSD.org
Mon Oct 6 14:11:27 CEST 2014


commit 54fe085352af60884182739dd53ccd1bbb2adc7a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 6 12:10:43 2014 +0000

    Also neuter do_gzip and do_gunzip if content length is zero

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 8045cd4..674845d 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -536,12 +536,12 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	/* It can't be both */
 	assert(bo->is_gzip == 0 || bo->is_gunzip == 0);
 
-	/* We won't gunzip unless it is gzip'ed */
-	if (bo->do_gunzip && !bo->is_gzip)
+	/* We won't gunzip unless it is non-empty and gzip'ed */
+	if (bo->htc->content_length == 0 || (bo->do_gunzip && !bo->is_gzip))
 		bo->do_gunzip = 0;
 
-	/* We wont gzip unless it is ungziped */
-	if (bo->do_gzip && !bo->is_gunzip)
+	/* We wont gzip unless it is non-empty and ungziped */
+	if (bo->htc->content_length == 0 || (bo->do_gzip && !bo->is_gunzip))
 		bo->do_gzip = 0;
 
 	/* But we can't do both at the same time */
diff --git a/bin/varnishtest/tests/r01602.vtc b/bin/varnishtest/tests/r01602.vtc
index 993bdaa..4411304 100644
--- a/bin/varnishtest/tests/r01602.vtc
+++ b/bin/varnishtest/tests/r01602.vtc
@@ -12,6 +12,7 @@ server s1 {
 varnish v1 -vcl+backend {
 	sub vcl_backend_response {
 		set beresp.do_esi = true;
+		set beresp.do_gzip = true;
 	}
 } -start
 



More information about the varnish-commit mailing list