Use $Restrict

parent c834a405
......@@ -15,9 +15,7 @@ varnish v1 -vcl+backend {
}
sub vcl_recv {
# wrong, triggers error
blobsynth.synthetic(gif.get());
return(synth(200));
return (synth(200));
}
sub vcl_synth {
......@@ -27,11 +25,6 @@ varnish v1 -vcl+backend {
}
} -start
logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI {^Rd vcl.load}
expect 1001 * VCL_Error {^blobsynth.synthetic.. only valid in}
} -start
client c1 {
txreq -url "/"
rxresp
......@@ -40,4 +33,18 @@ client c1 {
client c1 -run
logexpect l1 -wait
varnish v1 -errvcl {Not available in subroutine 'vcl_recv'} {
import blob;
import ${vmod_blobsynth};
sub vcl_init {
new gif = blob.blob(BASE64,
"R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
}
sub vcl_recv {
# wrong, triggers error
blobsynth.synthetic(gif.get());
return(synth(200));
}
}
\ No newline at end of file
......@@ -16,12 +16,7 @@ vmod_synthetic(VRT_CTX, VCL_BLOB body)
{
struct vsb *vsb;
if ((ctx->method & (VCL_MET_SYNTH | VCL_MET_BACKEND_ERROR)) == 0) {
VSLb(ctx->vsl, SLT_VCL_Error,
"blobsynth.synthetic() only valid in vcl_synth{}"
" and vcl_backend_error{}");
return;
}
AN(ctx->method & (VCL_MET_SYNTH | VCL_MET_BACKEND_ERROR));
CAST_OBJ_NOTNULL(vsb, ctx->specific, VSB_MAGIC);
......
......@@ -14,6 +14,4 @@ $Function VOID synthetic(BLOB blob)
Create a synthetic response from *blob*, equivalent to the
``synthetic()`` built-in function except for the argument type.
Needs to be called from ``vcl_synth`` or
``vcl_backend_error``. Otherwise, the function has no effect other
than logging a ``VCL_Error`` message to VSL.
$Restrict vcl_synth vcl_backend_error
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