Use $Restrict - previous push was premature

parent 3a5b4d83
......@@ -107,8 +107,7 @@ new xvdp = pipe.vdp(STRING path, STRING name, BYTES bufsz, DURATION timeout)
)
Define a VDP that transforms client responses by piping them through
the program located at ``path``. The constructor may only be called in
``vcl_init``.
the program located at ``path``.
The ``path`` parameter is required, MAY NOT be empty, and MUST specify
the absolute location of the file; the ``PATH`` environment variable
......@@ -203,14 +202,16 @@ VOID xvdp.arg(STRING)
---------------------
The ``.arg()`` method sets a command-line argument to be used with a
program. The method MAY NOT be called in any VCL subroutine besides
``vcl_init`` or ``vcl_deliver``. Invocations of ``.arg()`` in
``vcl_init`` set arguments to be used globally in the VCL
instance. Invocations in ``vcl_deliver`` set arguments to be used for
a single client response, overriding any arguments that may have been
set in ``vcl_init`` For example, you can call ``.arg()`` in
``vcl_deliver`` if the arguments to be used are not known until
runtime.
program.
Restricted to: ``vcl_init``, ``vcl_deliver``.
Invocations of ``.arg()`` in ``vcl_init`` set arguments to be used
globally in the VCL instance. Invocations in ``vcl_deliver`` set
arguments to be used for a single client response, overriding any
arguments that may have been set in ``vcl_init`` For example, you can
call ``.arg()`` in ``vcl_deliver`` if the arguments to be used are not
known until runtime.
The parameter in ``.arg()`` MAY be empty (if you need the empty string
as a CLI argument), but MAY NOT be NULL (for example, it may not be
......@@ -236,7 +237,7 @@ The CLI arguments for a command are ordered as the order in which
tr.arg(resp.http.X-TR-Set2);
}
set resp.filters = "tr";
}
}
You can leave ``.arg()`` out of ``vcl_init``, and only call it in
``vcl_deliver``, if the values of the arguments are only known at
......@@ -276,11 +277,12 @@ VOID xvdp.setenv(STRING var, STRING value, BOOL overwrite)
Set the environment variable ``var`` to ``value`` in the invoked
process.
Like ``.arg()``, ``.setenv()`` MAY NOT be called in any VCL subroutine
besides ``vcl_init`` or ``vcl_deliver``. Settings in ``vcl_init`` are
global for the VCL instance, while settings in ``vcl_deliver`` are
valid for a single client response (for use cases where the
environment settings are not known until runtime).
Restricted to: ``vcl_init``, ``vcl_deliver``.
Settings in ``vcl_init`` are global for the VCL instance, while
settings in ``vcl_deliver`` are valid for a single client response
(for use cases where the environment settings are not known until
runtime).
Currently, any invocation of ``.setenv()`` in ``vcl_deliver`` cancels
all environment settings specified in ``vcl_init`` for the current
......
......@@ -235,7 +235,7 @@ client c1 {
logexpect l1 -wait
varnish v1 -vcl+backend {
varnish v1 -errvcl {Not available in subroutine} {
import ${vmod_pipe};
sub vcl_init {
......@@ -247,19 +247,6 @@ varnish v1 -vcl+backend {
}
}
logexpect l1 -v v1 -g vxid -d 0 -q VCL_Error {
expect 0 * Begin {^req \d+ rxreq$}
expect * = VCL_Error {^vdp pipe failure: cat\.arg\(\): may only be called in vcl_init or vcl_deliver$}
expect * = End
} -start
client c1 {
txreq
rxresp -no_obj
} -run
logexpect l1 -wait
varnish v1 -vcl { backend b None; }
# Tests oject finalization, freeing argv
......
......@@ -101,12 +101,6 @@ varnish v1 -vcl+backend {
new env = pipe.vdp("${env}");
}
sub vcl_recv {
if (req.http.Test == "Illegal-Sub") {
env.setenv("FOO", "bar");
}
}
sub vcl_deliver {
if (req.http.Test == "Empty-Var") {
env.setenv("", "foo");
......@@ -151,13 +145,6 @@ client c1 {
expect resp.reason == "VCL failed"
} -run
client c1 {
txreq -hdr "Test: Illegal-Sub"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
} -run
logexpect l1 -v v1 -g vxid -d 1 -q VCL_Error {
expect 0 * Begin {^req \d+ rxreq$}
expect * = VCL_Error {^vdp pipe failure: env\.setenv\(\): var is empty$}
......@@ -174,10 +161,6 @@ logexpect l1 -v v1 -g vxid -d 1 -q VCL_Error {
expect 0 * Begin {^req \d+ rxreq$}
expect * = VCL_Error {^vdp pipe failure: env\.setenv\(\): value is NULL$}
expect * = End
expect 0 * Begin {^req \d+ rxreq$}
expect * = VCL_Error {^vdp pipe failure: env\.setenv\(\): may only be called in vcl_init or vcl_deliver$}
expect * = End
} -run
varnish v1 -vcl { backend b None; }
......@@ -188,3 +171,15 @@ varnish v1 -cli "vcl.discard vcl2"
varnish v1 -cli "vcl.discard vcl3"
delay 1
varnish v1 -cli "vcl.list"
varnish v1 -errvcl {Not available in subroutine} {
import ${vmod_pipe};
sub vcl_init {
new env = pipe.vdp("${env}");
}
sub vcl_recv {
env.setenv("FOO", "bar");
}
}
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