Use $Restrict

parent d14cb1ea
/*-
* Copyright (c) 2019 UPLEX Nils Goroll Systemoptimierung
* Copyright 2019, 2023 UPLEX Nils Goroll Systemoptimierung
* All rights reserved
*
* Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
......@@ -793,11 +793,7 @@ vmod_vdp_arg(VRT_CTX, struct VPFX(pipe_vdp) *obj, VCL_STRING arg)
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
CHECK_OBJ_NOTNULL(obj, PIPE_VDP_MAGIC);
if (!(ctx->method & (VCL_MET_INIT | VCL_MET_DELIVER))) {
VDPFAIL(ctx, "%s.arg(): may only be called in vcl_init or "
"vcl_deliver", obj->name);
return;
}
AN(ctx->method & (VCL_MET_INIT | VCL_MET_DELIVER));
if (arg == NULL) {
VDPFAIL(ctx, "%s.arg(): arg is NULL", obj->name);
......@@ -871,11 +867,7 @@ vmod_vdp_setenv(VRT_CTX, struct VPFX(pipe_vdp) *obj, VCL_STRING var,
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
CHECK_OBJ_NOTNULL(obj, PIPE_VDP_MAGIC);
if (!(ctx->method & (VCL_MET_INIT | VCL_MET_DELIVER))) {
VDPFAIL(ctx, "%s.setenv(): may only be called in vcl_init or "
"vcl_deliver", obj->name);
return;
}
AN(ctx->method & (VCL_MET_INIT | VCL_MET_DELIVER));
if (var == NULL || *var == '\0') {
VDPFAIL(ctx, "%s.setenv(): var is empty", obj->name);
......
......@@ -91,8 +91,7 @@ For example, to execute the VDPs shown above after ESI processing::
$Object vdp(STRING path, STRING name=0, BYTES bufsz=0, DURATION timeout=60)
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
......@@ -184,14 +183,16 @@ A complete example::
$Method VOID .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.
$Restrict 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
......@@ -217,7 +218,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
......@@ -250,11 +251,12 @@ $Method VOID .setenv(STRING var, STRING value, BOOL overwrite=1)
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).
$Restrict 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
......
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