]> err.no Git - varnish/commitdiff
Fix #320: All esi:includes should be picked up with GET,
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 25 Sep 2008 21:39:02 +0000 (21:39 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 25 Sep 2008 21:39:02 +0000 (21:39 +0000)
also if the original request was a PASS'ed POST.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3225 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishd/cache_vrt_esi.c
varnish-cache/bin/varnishtest/tests/e00011.vtc [new file with mode: 0644]

index b6c0457ba50e7df78b905a5db10bd9dc33a96050..f80d59d0f7f1ff1eb73461640a6c54914324ba1c 100644 (file)
@@ -473,6 +473,7 @@ void http_PutResponse(struct worker *w, int fd, struct http *to, const char *res
 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);
index fa978799225442c3c3a5ed586ee8ee0bfae6bb35..65edc254bcbefe0fd6b984993c2da239d8309389 100644 (file)
@@ -576,6 +576,13 @@ http_copyreq(struct http *to, const struct http *fm, int how)
        http_copyh(to, fm, HTTP_HDR_URL);
 }
 
+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)
 {
index 181b55b7315a8d49301fb7655548776d43170d3f..543814508ceb77abaedc589c869ee8544a08153e 100644 (file)
@@ -829,6 +829,7 @@ ESI_Deliver(struct sess *sp)
                        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;
diff --git a/varnish-cache/bin/varnishtest/tests/e00011.vtc b/varnish-cache/bin/varnishtest/tests/e00011.vtc
new file mode 100644 (file)
index 0000000..08b5f1c
--- /dev/null
@@ -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