r5697 - in trunk/varnish-cache/bin: varnishd varnishtest/tests

phk at varnish-cache.org phk at varnish-cache.org
Thu Jan 6 23:14:54 CET 2011


Author: phk
Date: 2011-01-06 23:14:54 +0100 (Thu, 06 Jan 2011)
New Revision: 5697

Added:
   trunk/varnish-cache/bin/varnishtest/tests/g00002.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_gzip.c
   trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Make sure we handle segmentet storage correctly when gunzip'ing
a response.



Modified: trunk/varnish-cache/bin/varnishd/cache_gzip.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_gzip.c	2011-01-06 22:14:00 UTC (rev 5696)
+++ trunk/varnish-cache/bin/varnishd/cache_gzip.c	2011-01-06 22:14:54 UTC (rev 5697)
@@ -119,6 +119,7 @@
 
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 
+	AZ(vg->vz.avail_in);
 	vg->vz.next_in = TRUST_ME(ptr);
 	vg->vz.avail_in = len;
 
@@ -126,7 +127,7 @@
 }
 
 /*--------------------------------------------------------------------*/
-
+#include <stdio.h>
 int
 VGZ_Produce(struct vgz *vg, const void **pptr, size_t *plen)
 {
@@ -148,6 +149,9 @@
 		return (0);
 	if (i == Z_STREAM_END)
 		return (1);
+	if (i == Z_BUF_ERROR)
+		return (2);
+fprintf(stderr, "--------------------> GUNZIP = %d\n", i);
 	return (-1);
 }
 

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c	2011-01-06 22:14:00 UTC (rev 5696)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c	2011-01-06 22:14:54 UTC (rev 5697)
@@ -275,6 +275,7 @@
 				if (WRW_Flush(sp->wrk))
 					break;
 			}
+			assert(i >= 0);
 		} while (i == 0);
 	}
 	VGZ_Destroy(&vg);

Added: trunk/varnish-cache/bin/varnishtest/tests/g00002.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/g00002.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/g00002.vtc	2011-01-06 22:14:54 UTC (rev 5697)
@@ -0,0 +1,55 @@
+# $Id$
+
+test "test basic gunzip for client"
+
+server s1 {
+	rxreq
+	expect req.http.accept-encoding == "gzip"
+	expect req.url == "/foo"
+	txresp -nolen -gziplen 4100
+	accept
+	rxreq
+	expect req.url == "/bar"
+	txresp -body {<H1><esi:include src="/foo"/></H1>}
+} -start
+
+varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend {
+
+	sub vcl_fetch {
+		esi;
+	}
+} -start
+
+varnish v1 -cliok "param.set fetch_chunksize 4"
+
+client c1 {
+	txreq -url /foo -hdr "Accept-Encoding: gzip"
+	rxresp
+	gunzip
+	expect resp.http.content-encoding == "gzip"
+	expect resp.bodylen == 4100
+} -run
+
+# If this fails, the multiple storage allocations did not happen
+varnish v1 -expect SMF.s0.nreq == 3
+
+client c1 {
+	# See varnish can gunzip it.
+	txreq -url /foo -hdr "Accept-Encoding: null"
+	rxresp
+	expect resp.http.content-encoding == "resp.http.content-encoding"
+	expect resp.bodylen == 4100
+
+	# See varnish can gunzip it, inside ESI
+	txreq -url /bar -hdr "Accept-Encoding: null"
+	rxresp
+	expect resp.http.content-encoding == "resp.http.content-encoding"
+	expect resp.bodylen == 4109
+
+	# See varnish can deliver gzip'ed ESI (NOTYET)
+	#txreq -url /bar -hdr "Accept-Encoding: gzip"
+	#rxresp
+	# expect resp.http.content-encoding == "gzip"
+	#gunzip
+	#expect resp.bodylen == 4109
+} -run




More information about the varnish-commit mailing list