From 8cdd4f8d238813aea7c639c85886f19a971ade8a Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Thu, 2 Oct 2008 13:46:42 +0200 Subject: [PATCH] Make sure error works in vcl_fetch error was unimplemented in vcl_fetch. Implement it and add a test case. --- 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