Use $Restrict

parent d14cb1ea
/*- /*-
* Copyright (c) 2019 UPLEX Nils Goroll Systemoptimierung * Copyright 2019, 2023 UPLEX Nils Goroll Systemoptimierung
* All rights reserved * All rights reserved
* *
* Author: Geoffrey Simmons <geoffrey.simmons@uplex.de> * Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
...@@ -793,11 +793,7 @@ vmod_vdp_arg(VRT_CTX, struct VPFX(pipe_vdp) *obj, VCL_STRING arg) ...@@ -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(ctx->ws, WS_MAGIC);
CHECK_OBJ_NOTNULL(obj, PIPE_VDP_MAGIC); CHECK_OBJ_NOTNULL(obj, PIPE_VDP_MAGIC);
if (!(ctx->method & (VCL_MET_INIT | VCL_MET_DELIVER))) { AN(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;
}
if (arg == NULL) { if (arg == NULL) {
VDPFAIL(ctx, "%s.arg(): arg is NULL", obj->name); 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, ...@@ -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(ctx->ws, WS_MAGIC);
CHECK_OBJ_NOTNULL(obj, PIPE_VDP_MAGIC); CHECK_OBJ_NOTNULL(obj, PIPE_VDP_MAGIC);
if (!(ctx->method & (VCL_MET_INIT | VCL_MET_DELIVER))) { AN(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;
}
if (var == NULL || *var == '\0') { if (var == NULL || *var == '\0') {
VDPFAIL(ctx, "%s.setenv(): var is empty", obj->name); VDPFAIL(ctx, "%s.setenv(): var is empty", obj->name);
......
...@@ -91,8 +91,7 @@ For example, to execute the VDPs shown above after ESI processing:: ...@@ -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) $Object vdp(STRING path, STRING name=0, BYTES bufsz=0, DURATION timeout=60)
Define a VDP that transforms client responses by piping them through Define a VDP that transforms client responses by piping them through
the program located at ``path``. The constructor may only be called in the program located at ``path``.
``vcl_init``.
The ``path`` parameter is required, MAY NOT be empty, and MUST specify The ``path`` parameter is required, MAY NOT be empty, and MUST specify
the absolute location of the file; the ``PATH`` environment variable the absolute location of the file; the ``PATH`` environment variable
...@@ -184,14 +183,16 @@ A complete example:: ...@@ -184,14 +183,16 @@ A complete example::
$Method VOID .arg(STRING) $Method VOID .arg(STRING)
The ``.arg()`` method sets a command-line argument to be used with a 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 program.
``vcl_init`` or ``vcl_deliver``. Invocations of ``.arg()`` in
``vcl_init`` set arguments to be used globally in the VCL $Restrict vcl_init vcl_deliver
instance. Invocations in ``vcl_deliver`` set arguments to be used for
a single client response, overriding any arguments that may have been Invocations of ``.arg()`` in ``vcl_init`` set arguments to be used
set in ``vcl_init`` For example, you can call ``.arg()`` in globally in the VCL instance. Invocations in ``vcl_deliver`` set
``vcl_deliver`` if the arguments to be used are not known until arguments to be used for a single client response, overriding any
runtime. 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 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 as a CLI argument), but MAY NOT be NULL (for example, it may not be
...@@ -250,11 +251,12 @@ $Method VOID .setenv(STRING var, STRING value, BOOL overwrite=1) ...@@ -250,11 +251,12 @@ $Method VOID .setenv(STRING var, STRING value, BOOL overwrite=1)
Set the environment variable ``var`` to ``value`` in the invoked Set the environment variable ``var`` to ``value`` in the invoked
process. process.
Like ``.arg()``, ``.setenv()`` MAY NOT be called in any VCL subroutine $Restrict vcl_init vcl_deliver
besides ``vcl_init`` or ``vcl_deliver``. Settings in ``vcl_init`` are
global for the VCL instance, while settings in ``vcl_deliver`` are Settings in ``vcl_init`` are global for the VCL instance, while
valid for a single client response (for use cases where the settings in ``vcl_deliver`` are valid for a single client response
environment settings are not known until runtime). (for use cases where the environment settings are not known until
runtime).
Currently, any invocation of ``.setenv()`` in ``vcl_deliver`` cancels Currently, any invocation of ``.setenv()`` in ``vcl_deliver`` cancels
all environment settings specified in ``vcl_init`` for the current 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