Commit 93813517 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Implement restart in vcl_deliver(), and add test case for it.

Fixes: #411


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5644 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f5f00f63
......@@ -191,8 +191,18 @@ cnt_deliver(struct sess *sp)
case VCL_RET_DELIVER:
break;
case VCL_RET_RESTART:
INCOMPL();
break;
if (sp->restarts >= params->max_restarts)
break;
(void)HSH_Deref(sp->wrk, NULL, &sp->obj);
AZ(sp->obj);
sp->restarts++;
sp->director = NULL;
sp->wrk->bereq = NULL;
sp->wrk->beresp = NULL;
sp->wrk->beresp1 = NULL;
sp->wrk->resp = NULL;
sp->step = STP_RECV;
return (0);
default:
WRONG("Illegal action in vcl_deliver{}");
}
......
# $Id$
test "Test restart in vcl_deliver"
server s1 {
rxreq
expect req.url == "/foo"
txresp -status 303 -hdr "Location: /bar"
rxreq
expect req.url == "/bar"
txresp -status 200 -body "1"
} -start
varnish v1 -vcl+backend {
sub vcl_hit {
if (obj.http.X-Magic-Redirect == "1") {
set req.url = obj.http.Location;
return (restart);
}
}
sub vcl_fetch {
if (beresp.status == 303) {
set beresp.cacheable = true;
set beresp.http.X-Magic-Redirect = "1";
}
}
sub vcl_deliver {
if (resp.http.X-Magic-Redirect == "1") {
return (restart);
}
set resp.http.X-Restarts = req.restarts;
}
} -start
client c1 {
txreq -url "/foo"
rxresp
expect resp.status == 200
expect resp.bodylen == 1
expect resp.http.X-Restarts == "2"
txreq -url "/foo"
rxresp
expect resp.status == 200
expect resp.bodylen == 1
expect resp.http.X-Restarts == "1"
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment