Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvdfp-pipe
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvdfp-pipe
Commits
0c4b3341
Commit
0c4b3341
authored
Aug 11, 2020
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document .setenv().
parent
723690f9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
2 deletions
+112
-2
README.rst
README.rst
+56
-1
vdfp_pipe.vcc
src/vdfp_pipe.vcc
+56
-1
No files found.
README.rst
View file @
0c4b3341
...
@@ -273,7 +273,62 @@ VOID xvdp.setenv(STRING var, STRING value, BOOL overwrite)
...
@@ -273,7 +273,62 @@ VOID xvdp.setenv(STRING var, STRING value, BOOL overwrite)
VOID xvdp.setenv(STRING var, STRING value, BOOL overwrite=1)
VOID xvdp.setenv(STRING var, STRING value, BOOL overwrite=1)
XXX ...
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).
Currently, any invocation of ``.setenv()`` in ``vcl_deliver`` cancels
all environment settings specified in ``vcl_init`` for the current
client response. For example, if you set a value for the variable
``FOO`` in ``vcl_init`` and ``BAR`` in ``vcl_deliver``, then ``FOO`` is
not set, unless you also set ``FOO`` in ``vcl_deliver`` (if necessary
to the same value).
The variable name ``var`` MAY NOT be empty or NULL, and MAY NOT
contain the equals sign (``=``). ``value`` MAY be empty (to set the
empty string as the value), but MAY NOT be NULL. A string is NULL, for
example, if you specify an unset header.
If the optional parameter ``overwrite`` is ``true``, then if ``var``
is already set in the process environment (for example, due to
inheritance from the varnishd worker process, or after a previous
invocation of ``.setenv()`` for the same variable), then its value is
is changed to ``value``. If ``overwrite`` is ``false``, any previous
value is left unchanged (this is not an error). By default,
``overwrite`` is ``true``.
Environment variables are set in the same order as ``.setenv()``
invocations in VCL. So if the same variable is set by ``.setenv()``
more than once, then the value in the last invocation is set, unless
``overwrite`` is false in that invocation.
For example::
sub vcl_init {
# Global environment settings, unless overridden in vcl_deliver.
new app = pipe.vdp("/usr/bin/myapp");
app.setenv("FOO", "bar");
app.setenv("BAZ", "quux");
app.setenv("NOTHING", "");
# Set this value for LANG unless it is already set due to
# inheritance from varnishd.
app.setenv("LANG", "de_DE.UTF8", overwrite=false);
}
sub vcl_deliver {
# For this URL, set different values in the environment.
if (req.url == "/bazooka") {
# NOTHING and LANG not set for this response.
app.setenv("FOO", "fighter");
app.setenv("BAZ", "ooka");
}
set resp.filters = "app";
}
.. _pipe.version():
.. _pipe.version():
...
...
src/vdfp_pipe.vcc
View file @
0c4b3341
...
@@ -247,7 +247,62 @@ can be implemented more efficiently by using the ``-u`` argument with
...
@@ -247,7 +247,62 @@ can be implemented more efficiently by using the ``-u`` argument with
$Method VOID .setenv(STRING var, STRING value, BOOL overwrite=1)
$Method VOID .setenv(STRING var, STRING value, BOOL overwrite=1)
XXX ...
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).
Currently, any invocation of ``.setenv()`` in ``vcl_deliver`` cancels
all environment settings specified in ``vcl_init`` for the current
client response. For example, if you set a value for the variable
``FOO`` in ``vcl_init`` and ``BAR`` in ``vcl_deliver``, then ``FOO`` is
not set, unless you also set ``FOO`` in ``vcl_deliver`` (if necessary
to the same value).
The variable name ``var`` MAY NOT be empty or NULL, and MAY NOT
contain the equals sign (``=``). ``value`` MAY be empty (to set the
empty string as the value), but MAY NOT be NULL. A string is NULL, for
example, if you specify an unset header.
If the optional parameter ``overwrite`` is ``true``, then if ``var``
is already set in the process environment (for example, due to
inheritance from the varnishd worker process, or after a previous
invocation of ``.setenv()`` for the same variable), then its value is
is changed to ``value``. If ``overwrite`` is ``false``, any previous
value is left unchanged (this is not an error). By default,
``overwrite`` is ``true``.
Environment variables are set in the same order as ``.setenv()``
invocations in VCL. So if the same variable is set by ``.setenv()``
more than once, then the value in the last invocation is set, unless
``overwrite`` is false in that invocation.
For example::
sub vcl_init {
# Global environment settings, unless overridden in vcl_deliver.
new app = pipe.vdp("/usr/bin/myapp");
app.setenv("FOO", "bar");
app.setenv("BAZ", "quux");
app.setenv("NOTHING", "");
# Set this value for LANG unless it is already set due to
# inheritance from varnishd.
app.setenv("LANG", "de_DE.UTF8", overwrite=false);
}
sub vcl_deliver {
# For this URL, set different values in the environment.
if (req.url == "/bazooka") {
# NOTHING and LANG not set for this response.
app.setenv("FOO", "fighter");
app.setenv("BAZ", "ooka");
}
set resp.filters = "app";
}
$Function STRING version()
$Function STRING version()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment