]> err.no Git - varnish/commitdiff
Make sure error works in vcl_fetch
authorTollef Fog Heen <tfheen@err.no>
Thu, 2 Oct 2008 11:46:42 +0000 (13:46 +0200)
committerTollef Fog Heen <tfheen@err.no>
Tue, 7 Oct 2008 10:03:35 +0000 (12:03 +0200)
error was unimplemented in vcl_fetch.  Implement it and add a test
case.

varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishtest/tests/b00018.vtc [new file with mode: 0644]

index 63355b0125935b988fe7a446eaa305d14384cbe4..1bc73f1c81e3e62de43c1b64abca31ff8a8a1aec 100644 (file)
@@ -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 (file)
index 0000000..ad27f0f
--- /dev/null
@@ -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