[master] 6cd23c2 Fix HEAD requests with ESI processing: Only call vfp->end if we called vfp->begin.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Mar 14 09:38:56 CET 2011
commit 6cd23c2a5a9028e42161389fac750f95d5bb77ec
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Mar 14 08:38:00 2011 +0000
Fix HEAD requests with ESI processing: Only call vfp->end if we
called vfp->begin.
Fixes: #871, #870
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index 594aa4e..78c7af8 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -514,14 +514,17 @@ FetchBody(struct sess *sp)
cls = fetch_straight(sp, sp->wrk->htc,
sp->wrk->h_content_length);
mklen = 1;
+ XXXAZ(sp->wrk->vfp->end(sp));
break;
case BS_CHUNKED:
cls = fetch_chunked(sp, sp->wrk->htc);
mklen = 1;
+ XXXAZ(sp->wrk->vfp->end(sp));
break;
case BS_EOF:
cls = fetch_eof(sp, sp->wrk->htc);
mklen = 1;
+ XXXAZ(sp->wrk->vfp->end(sp));
break;
case BS_ERROR:
cls = 1;
@@ -532,8 +535,8 @@ FetchBody(struct sess *sp)
mklen = 0;
INCOMPL();
}
- XXXAZ(sp->wrk->vfp->end(sp));
AZ(sp->wrk->vgz_rx);
+
/*
* It is OK for ->end to just leave the last storage segment
* sitting on sp->wrk->storage, we will always call vfp_nop_end()
diff --git a/bin/varnishtest/tests/e00027.vtc b/bin/varnishtest/tests/e00027.vtc
new file mode 100644
index 0000000..041c0ee
--- /dev/null
+++ b/bin/varnishtest/tests/e00027.vtc
@@ -0,0 +1,27 @@
+# $Id$
+
+test "test HEAD against ESI processing"
+
+server s1 {
+ rxreq
+ expect req.url == "/1"
+ txresp -bodylen 1
+
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_fetch {
+ set beresp.do_esi = true;
+ }
+} -start
+
+client c1 {
+ txreq -url "/1"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 1
+
+ txreq -req "HEAD" -url "/1"
+ rxresp -no_obj
+ expect resp.status == 200
+} -run
More information about the varnish-commit
mailing list