[master] fd08146 Add another easy bit of code: including a ungzip'ed non-ESI object in an gzip'ed ESI object.

Poul-Henning Kamp phk at project.varnish-software.com
Sat Jan 22 14:55:38 CET 2011


commit fd081460f887db22ae90f091010a179744c3bf71
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sat Jan 22 13:55:07 2011 +0000

    Add another easy bit of code:  including a ungzip'ed non-ESI object
    in an gzip'ed ESI object.

diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index 3ea26ca..a2ed4cc 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -815,6 +815,7 @@ char *VRT_String(struct ws *ws, const char *h, const char *p, va_list ap);
 char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap);
 
 void ESI_Deliver(struct sess *);
+void ESI_DeliverChild(struct sess *);
 
 /* cache_vrt_vmod.c */
 void VMOD_Init(void);
diff --git a/bin/varnishd/cache_esi_deliver.c b/bin/varnishd/cache_esi_deliver.c
index ca581f8..a3c9dc5 100644
--- a/bin/varnishd/cache_esi_deliver.c
+++ b/bin/varnishd/cache_esi_deliver.c
@@ -333,3 +333,20 @@ ESI_Deliver(struct sess *sp)
 	}
 	(void)WRW_Flush(sp->wrk);
 }
+
+/*---------------------------------------------------------------------
+ * Include an object in a gzip'ed ESI object delivery
+ */
+
+void
+ESI_DeliverChild(struct sess *sp)
+{
+	struct storage *st;
+
+	if (sp->obj->gziped) {
+		INCOMPL();
+	} else {
+		VTAILQ_FOREACH(st, &sp->obj->store, list)
+			ved_pretend_gzip(sp, st->ptr, st->len);
+	}
+}
diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 31818e8..6347d82 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -390,6 +390,8 @@ RES_WriteObj(struct sess *sp)
 		/* Nothing to do here */
 	} else if (sp->wrk->res_mode & RES_ESI) {
 		ESI_Deliver(sp);
+	} else if (sp->wrk->res_mode & RES_ESI_CHILD && sp->wrk->gzip_resp) {
+		ESI_DeliverChild(sp);
 	} else if (sp->wrk->res_mode & RES_GUNZIP) {
 		res_WriteGunzipObj(sp); 
 	} else {
diff --git a/bin/varnishtest/tests/e00023.vtc b/bin/varnishtest/tests/e00023.vtc
index c493fa6..0d4457c 100644
--- a/bin/varnishtest/tests/e00023.vtc
+++ b/bin/varnishtest/tests/e00023.vtc
@@ -1,19 +1,24 @@
 # $Id$
 
-test "Include an ungzip'ed ESI object in a gzip'ed ESI object"
+test "Include an ungzip'ed (ESI) object in a gzip'ed ESI object"
 
 server s1 {
 	rxreq 
 	expect req.http.accept-encoding == gzip
 	txresp -gzipbody {
 		<html>					1
-		Before include				2
+		Before includes				2
 		<esi:include src="/foo"/>		3
-		After include				4
+		Between includes			4
+		<esi:include src="/bar"/>		5
+		After includes				6
 	}
 	rxreq
 	expect req.url == "/foo"
 	txresp -body {<h1>/////<h2>}
+	rxreq
+	expect req.url == "/bar"
+	txresp -body {*****}
 } -start
 
 varnish v1 -vcl+backend {
@@ -33,7 +38,7 @@ client c1 {
 	expect resp.http.content-encoding == gzip
 	gunzip
 	expect resp.status == 200
-	expect resp.bodylen == 79
+	expect resp.bodylen == 115
 }
 
 client c1 -run



More information about the varnish-commit mailing list