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

phk at projects.linpro.no phk at projects.linpro.no
Thu Sep 25 23:39:03 CEST 2008


Author: phk
Date: 2008-09-25 23:39:02 +0200 (Thu, 25 Sep 2008)
New Revision: 3225

Added:
   trunk/varnish-cache/bin/varnishtest/tests/e00011.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_http.c
   trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
Log:
Fix #320:  All esi:includes should be picked up with GET,
also if the original request was a PASS'ed POST.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2008-09-25 12:35:50 UTC (rev 3224)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2008-09-25 21:39:02 UTC (rev 3225)
@@ -473,6 +473,7 @@
 void http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...);
 void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr);
 void http_SetH(struct http *to, unsigned n, const char *fm);
+void http_ForceGet(struct http *to);
 void http_Setup(struct http *ht, struct ws *ws);
 int http_GetHdr(const struct http *hp, const char *hdr, char **ptr);
 int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr);

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2008-09-25 12:35:50 UTC (rev 3224)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2008-09-25 21:39:02 UTC (rev 3225)
@@ -577,6 +577,13 @@
 }
 
 void
+http_ForceGet(struct http *to)
+{
+	if (strcmp(http_GetReq(to), "GET"))
+		http_SetH(to, HTTP_HDR_REQ, "GET");
+}
+
+void
 http_CopyResp(struct http *to, const struct http *fm)
 {
 

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c	2008-09-25 12:35:50 UTC (rev 3224)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c	2008-09-25 21:39:02 UTC (rev 3225)
@@ -829,6 +829,7 @@
 			http_SetHeader(sp->wrk, sp->fd, sp->http, eb->host.b);
 		}
 		sp->step = STP_RECV;
+		http_ForceGet(sp->http);
 		CNT_Session(sp);
 		sp->esis--;
 		sp->obj = obj;

Added: trunk/varnish-cache/bin/varnishtest/tests/e00011.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/e00011.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/e00011.vtc	2008-09-25 21:39:02 UTC (rev 3225)
@@ -0,0 +1,31 @@
+# $Id$
+
+test "Make sure that PASS'ed ESI requests use GET for includes"
+
+server s1 {
+	rxreq 
+	expect req.request == POST
+	expect req.url == /foobar
+	txresp -body {<HTML>
+		FOO
+		<esi:include src="/bar">
+	}
+	rxreq
+	expect req.request == GET
+	txresp -body {
+		BAR
+	}
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_fetch {
+		esi;
+	}
+} -start 
+
+client c1 {
+	txreq -req POST -url /foobar
+	rxresp
+	expect resp.status == 200
+	expect resp.bodylen == 25
+} -run




More information about the varnish-commit mailing list