add obj.can_esi

Ref #3002
parent 9fa55a59
......@@ -442,6 +442,17 @@ VRT_r_obj_storage(VRT_CTX)
/*--------------------------------------------------------------------*/
VCL_BOOL
VRT_r_obj_can_esi(VRT_CTX)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
return (ObjHasAttr(ctx->req->wrk, ctx->req->objcore, OA_ESIDATA));
}
/*--------------------------------------------------------------------*/
#define REQ_VAR_L(nm, elem, type, extra) \
\
VCL_VOID \
......
......@@ -12,6 +12,9 @@ varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.do_esi = true;
}
sub vcl_deliver {
set resp.http.can_esi = obj.can_esi;
}
} -start
logexpect l1 -v v1 -g raw {
......@@ -23,6 +26,7 @@ client c1 {
rxresp
expect resp.status == 200
expect resp.bodylen == 33
expect resp.http.can_esi == "false"
}
client c1 -run
......
......@@ -17,6 +17,9 @@ varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.do_esi = true;
}
sub vcl_deliver {
set resp.http.can_esi = obj.can_esi;
}
} -start
logexpect l1 -v v1 -g raw {
......@@ -29,6 +32,7 @@ client c1 {
rxresp
expect resp.status == 200
expect resp.bodylen == 40
expect resp.http.can_esi == "true"
}
client c1 -run
......
......@@ -32,12 +32,15 @@ varnish v1 -vcl+backend {
set beresp.do_esi = true;
}
}
sub vcl_deliver {
set resp.http.can_esi = obj.can_esi;
}
} -start
logexpect l1 -v v1 -g request {
expect 0 1001 Begin "^req .* rxreq"
# ReqAcct body counts include chunked overhead
expect * = ReqAcct "^29 0 29 187 104 291$"
expect * = ReqAcct "^29 0 29 202 104 306$"
expect 0 = End
} -start
......@@ -61,7 +64,7 @@ logexpect l5 -v v1 -g request {
expect * 1005 Begin "^req .* rxreq"
# ReqAcct body counts include chunked overhead
# Header bytes is 5 larger than in l1 due to two item X-Varnish hdr
expect * = ReqAcct "^29 0 29 192 104 296$"
expect * = ReqAcct "^29 0 29 207 104 311$"
expect 0 = End
} -start
......@@ -70,6 +73,7 @@ client c1 {
rxresp
expect resp.bodylen == 75
expect resp.status == 200
expect resp.http.can_esi == "true"
delay .1
# test that there is no difference on miss/hit
......@@ -77,6 +81,7 @@ client c1 {
rxresp
expect resp.bodylen == 75
expect resp.status == 200
expect resp.http.can_esi == "true"
}
client c1 -run
......
......@@ -14,12 +14,16 @@ varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.do_esi = true;
}
sub vcl_deliver {
set resp.http.can_esi = obj.can_esi;
}
} -start
client c1 {
txreq -hdr "Accept-Encoding: gzip"
rxresp
expect resp.status == 200
expect resp.http.can_esi == "true"
gunzip
expect resp.bodylen == 3
} -run
......@@ -1107,6 +1107,18 @@ obj.storage
The storage backend where this object is stored.
obj.can_esi
Type: BOOL
Readable from: vcl_hit, vcl_deliver
If the object can be ESI processed, that is if setting
``resp.do_esi`` or adding ``esi`` to ``resp.filters`` in
``vcl_deliver {}`` would cause the response body to be ESI
processed.
resp
~~~~
......
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