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

phk at projects.linpro.no phk at projects.linpro.no
Fri Mar 20 11:14:27 CET 2009


Author: phk
Date: 2009-03-20 11:14:27 +0100 (Fri, 20 Mar 2009)
New Revision: 3965

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00445
Modified:
   trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Fix for #445:  including zero length esi objects with chunked encoding.



Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c	2009-03-20 10:12:05 UTC (rev 3964)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c	2009-03-20 10:14:27 UTC (rev 3965)
@@ -152,7 +152,9 @@
 	}
 
 	if (sp->wantbody) {
-		if (sp->esis > 0 && sp->http->protover >= 1.1) {
+		if (sp->esis > 0 &&
+		    sp->http->protover >= 1.1 &&
+		    sp->obj->len > 0) {
 			sprintf(lenbuf, "%x\r\n", sp->obj->len);
 			(void)WRW_Write(sp->wrk, lenbuf, -1);
 		}
@@ -181,7 +183,9 @@
 			(void)WRW_Write(sp->wrk, st->ptr, st->len);
 		}
 		assert(u == sp->obj->len);
-		if (sp->esis > 0 && sp->http->protover >= 1.1)
+		if (sp->esis > 0 &&
+		    sp->http->protover >= 1.1 &&
+		    sp->obj->len > 0)
 			(void)WRW_Write(sp->wrk, "\r\n", -1);
 	}
 	if (WRW_FlushRelease(sp->wrk))

Added: trunk/varnish-cache/bin/varnishtest/tests/r00445
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00445	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00445	2009-03-20 10:14:27 UTC (rev 3965)
@@ -0,0 +1,24 @@
+# $Id$
+
+test "zero length ESI include segmens with chunked encoding"
+
+server s1 {
+	rxreq
+	expect req.url == "/"
+	txresp -body {<foo><esi:include src="/bar"><bar>}
+	rxreq
+	expect req.url == "/bar"
+	txresp 
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_fetch {
+		esi;
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.bodylen == 10
+} -run



More information about the varnish-commit mailing list