From 79656ae6f35bc9d3f8007a9c201723af69b96bfa Mon Sep 17 00:00:00 2001 From: tfheen Date: Tue, 7 Oct 2008 11:00:38 +0000 Subject: [PATCH] Make sure error works in vcl_fetch error was unimplemented in vcl_fetch. Implement it and add a test case. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3263 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_center.c | 8 +++++++ .../bin/varnishtest/tests/b00018.vtc | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 varnish-cache/bin/varnishtest/tests/b00018.vtc diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 63355b01..1bc73f1c 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -426,6 +426,14 @@ cnt_fetch(struct sess *sp) break; case VCL_RET_DELIVER: break; + case VCL_RET_ERROR: + sp->step = STP_ERROR; + sp->obj->ttl = 0; + sp->obj->cacheable = 0; + HSH_Unbusy(sp); + HSH_Deref(sp->obj); + sp->obj = NULL; + return (0); default: WRONG("Illegal action in vcl_fetch{}"); } diff --git a/varnish-cache/bin/varnishtest/tests/b00018.vtc b/varnish-cache/bin/varnishtest/tests/b00018.vtc new file mode 100644 index 00000000..ad27f0f5 --- /dev/null +++ b/varnish-cache/bin/varnishtest/tests/b00018.vtc @@ -0,0 +1,21 @@ +# $Id$ + +test "Check that error in vcl_fetch works" + +server s1 { + rxreq + txresp -body "012345\n" +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + set obj.http.Foo = "bar"; + error 523 "not ok"; + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 523 +} -run -- 2.39.5