Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
69838a5c
Commit
69838a5c
authored
Dec 02, 2016
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add std.getenv()
Merges #2152
parent
6dca8126
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
m00026.vtc
bin/varnishtest/tests/m00026.vtc
+21
-0
vmod.vcc
lib/libvmod_std/vmod.vcc
+8
-0
vmod_std.c
lib/libvmod_std/vmod_std.c
+9
-0
No files found.
bin/varnishtest/tests/m00026.vtc
0 → 100644
View file @
69838a5c
varnishtest "Test std.getenv"
varnish v1 -vcl {
import std;
backend dummy { .host = "${bad_ip}"; .port = "9080"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.X-PATH = std.getenv("PATH");
}
} -start
client c1 {
txreq
rxresp
expect resp.http.X-PATH ~ "^/"
} -run
lib/libvmod_std/vmod.vcc
View file @
69838a5c
...
@@ -274,6 +274,14 @@ Example
...
@@ -274,6 +274,14 @@ Example
| ...
| ...
| }
| }
$Function STRING getenv(STRING name)
Description
Return environment variable *name* or the empty string.
See getenv(3)
Example
| set req.http.My-Env = getenv("MY_ENV");
SEE ALSO
SEE ALSO
========
========
...
...
lib/libvmod_std/vmod_std.c
View file @
69838a5c
...
@@ -248,3 +248,12 @@ vmod_strstr(VRT_CTX, VCL_STRING s1, VCL_STRING s2)
...
@@ -248,3 +248,12 @@ vmod_strstr(VRT_CTX, VCL_STRING s1, VCL_STRING s2)
return
(
NULL
);
return
(
NULL
);
return
(
strstr
(
s1
,
s2
));
return
(
strstr
(
s1
,
s2
));
}
}
VCL_STRING
__match_proto__
(
td_std_getenv
)
vmod_getenv
(
VRT_CTX
,
VCL_STRING
name
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
name
==
NULL
||
*
name
==
'\0'
)
return
(
NULL
);
return
(
getenv
(
name
));
}
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