Commit 8311f0bc authored by Nils Goroll's avatar Nils Goroll

fix obj.hits in vcl_hit

Fixes #2746
parent cd4188f8
......@@ -806,6 +806,8 @@ VRT_r_obj_hits(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
if (ctx->method == VCL_MET_HIT)
return (ctx->req->objcore->hits);
return (ctx->req->is_hit ? ctx->req->objcore->hits : 0);
}
......
......@@ -18,8 +18,14 @@ varnish v1 -vcl+backend {
return (pass);
}
}
sub vcl_hit {
set req.http.hit-hits = obj.hits;
}
sub vcl_deliver {
set resp.http.foo = obj.hits;
set resp.http.deliver-hits = obj.hits;
if (req.http.hit-hits) {
set resp.http.hit-hits = req.http.hit-hits;
}
}
} -start
......@@ -27,26 +33,31 @@ client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.foo == 0
expect resp.http.deliver-hits == 0
expect resp.http.hit-hits == <undef>
txreq
rxresp
expect resp.status == 200
expect resp.http.foo == 1
expect resp.http.deliver-hits == 1
expect resp.http.hit-hits == 1
txreq -url /foo
rxresp
expect resp.status == 200
expect resp.http.foo == 0
expect resp.http.deliver-hits == 0
expect resp.http.hit-hits == <undef>
delay .1
txreq
rxresp
expect resp.status == 200
expect resp.http.foo == 2
expect resp.http.deliver-hits == 2
expect resp.http.hit-hits == 2
txreq -url /pass
rxresp
expect resp.status == 200
expect resp.http.foo == 0
expect resp.http.deliver-hits == 0
expect resp.http.hit-hits == <undef>
} -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