Commit cc2b4c4d authored by Nils Goroll's avatar Nils Goroll

Add std.cache_req_body to call VRT_CacheReqBody from VCL

Initial patch by Meng Zhnag - jammy.linux@gmail.com
parent 7e5ec4c6
...@@ -11,8 +11,10 @@ server s1 { ...@@ -11,8 +11,10 @@ server s1 {
} -start } -start
varnish v1 -cliok "param.set vcc_allow_inline_c true" -vcl+backend { varnish v1 -cliok "param.set vcc_allow_inline_c true" -vcl+backend {
import ${vmod_std};
sub vcl_recv { sub vcl_recv {
C{ VRT_CacheReqBody(ctx, 1000); }C std.cache_req_body(1KB);
return (pass); return (pass);
} }
sub vcl_deliver { sub vcl_deliver {
......
...@@ -31,8 +31,10 @@ client c1 { ...@@ -31,8 +31,10 @@ client c1 {
delay .2 delay .2
varnish v1 -cliok "param.set vcc_allow_inline_c true" -vcl+backend { varnish v1 -cliok "param.set vcc_allow_inline_c true" -vcl+backend {
import ${vmod_std};
sub vcl_recv { sub vcl_recv {
C{ VRT_CacheReqBody(ctx, 1000); }C std.cache_req_body(1000B);
} }
} }
......
...@@ -199,6 +199,14 @@ Description ...@@ -199,6 +199,14 @@ Description
Example Example
set req.url = std.querysort(req.url); set req.url = std.querysort(req.url);
$Function VOID cache_req_body(BYTES)
Description
Cache the req.body if it is smaller than the given size
Example
std.cache_req_body(1KB);
This will cache the req.body if its size is smaller than 1KB.
SEE ALSO SEE ALSO
......
...@@ -230,3 +230,12 @@ vmod_timestamp(const struct vrt_ctx *ctx, VCL_STRING label) ...@@ -230,3 +230,12 @@ vmod_timestamp(const struct vrt_ctx *ctx, VCL_STRING label)
VSLb_ts_req(ctx->req, label, VTIM_real()); VSLb_ts_req(ctx->req, label, VTIM_real());
} }
} }
VCL_VOID __match_proto__(td_std_cache_req_body)
vmod_cache_req_body(const struct vrt_ctx *ctx, VCL_BYTES size)
{
int result;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
result = VRT_CacheReqBody(ctx, size);
VSLb(ctx->vsl, SLT_Debug,"VRT_CacheReqBody[size: %zu] result: %d", (size_t)size, result);
}
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