From 6d4a385eaed32957c4e4e29dd5a49d26feacd26e Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 25 Sep 2008 21:39:02 +0000 Subject: [PATCH] Fix #320: All esi:includes should be picked up with GET, 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 | 1 + varnish-cache/bin/varnishd/cache_http.c | 7 +++++ varnish-cache/bin/varnishd/cache_vrt_esi.c | 1 + .../bin/varnishtest/tests/e00011.vtc | 31 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 varnish-cache/bin/varnishtest/tests/e00011.vtc diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index b6c0457b..f80d59d0 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -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); diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index fa978799..65edc254 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -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) { diff --git a/varnish-cache/bin/varnishd/cache_vrt_esi.c b/varnish-cache/bin/varnishd/cache_vrt_esi.c index 181b55b7..54381450 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_esi.c +++ b/varnish-cache/bin/varnishd/cache_vrt_esi.c @@ -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 index 00000000..08b5f1c7 --- /dev/null +++ b/varnish-cache/bin/varnishtest/tests/e00011.vtc @@ -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 { + FOO + + } + 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 -- 2.39.5