Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-file
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
libvmod-file
Commits
86cbff7b
Commit
86cbff7b
authored
Sep 28, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.synth() may also be called in vcl_backend_error.
parent
bb84630c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
16 deletions
+45
-16
README.rst
README.rst
+9
-4
synth.vtc
src/tests/synth.vtc
+24
-5
vmod_file.c
src/vmod_file.c
+3
-3
vmod_file.vcc
src/vmod_file.vcc
+9
-4
No files found.
README.rst
View file @
86cbff7b
...
...
@@ -312,10 +312,11 @@ message.
VOID xreader.synth()
--------------------
Generate a synthetic client response body from the file contents. This
method may only be called in ``vcl_synth``. Invokes VCL failure if the
most recent update check encountered an error, or if invoked in any
other VCL subroutine besides ``vcl_synth``.
Generate a synthetic response body from the file contents. This method
may only be called in ``vcl_synth`` or ``vcl_backend_error``. Invokes
VCL failure if the most recent update check encountered an error, or
if invoked in any other VCL subroutine besides the two that are
permitted.
Example::
...
...
@@ -323,6 +324,10 @@ Example::
synth_body.synth();
}
sub vcl_backend_error {
synth_body.synth();
}
.. _xreader.blob():
BLOB xreader.blob()
...
...
src/tests/synth.vtc
View file @
86cbff7b
...
...
@@ -2,22 +2,34 @@
varnishtest "reader.synth()"
shell {echo -n "foo bar baz quux" > ${tmpdir}/synth}
shell {
echo -n "foo bar baz quux" > ${tmpdir}/synth
echo -n "ouch" > ${tmpdir}/backend_error
}
varnish v1 -vcl {
import ${vmod_file};
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new rdr = file.reader("${tmpdir}/synth", ttl=0.1s);
new synth = file.reader("${tmpdir}/synth", ttl=0.1s);
new backend_err = file.reader("${tmpdir}/backend_error");
}
sub vcl_recv {
if (req.url == "/backend") {
return (pass);
}
return (synth(200));
}
sub vcl_synth {
rdr.synth();
synth.synth();
return (deliver);
}
sub vcl_backend_error {
backend_err.synth();
return (deliver);
}
} -start
...
...
@@ -39,6 +51,13 @@ client c1 {
expect resp.body == "quux baz bar foo"
} -run
client c1 {
txreq -url /backend
rxresp
expect resp.status == 503
expect resp.body == "ouch"
} -run
shell {chmod a-r ${tmpdir}/synth}
delay .1
...
...
@@ -49,7 +68,7 @@ client c1 {
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error {^
rdr\.synth\(\): vmod file failure: vcl1\.rdr
: cannot open}
expect * = VCL_Error {^
synth\.synth\(\): vmod file failure: vcl1\.synth
: cannot open}
expect * = End
} -run
...
...
@@ -73,7 +92,7 @@ varnish v1 -vcl {
logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error {^rdr\.synth\(\) may only be called in vcl_synth$}
expect * = VCL_Error {^rdr\.synth\(\) may only be called in vcl_synth
or vcl_backend_error
$}
expect * = End
} -start
...
...
src/vmod_file.c
View file @
86cbff7b
...
...
@@ -539,9 +539,9 @@ vmod_reader_synth(VRT_CTX, struct VPFX(file_reader) *rdr)
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
rdr
,
FILE_READER_MAGIC
);
if
((
ctx
->
method
&
VCL_MET_SYNTH
)
==
0
)
{
VRT_fail
(
ctx
,
"%s.synth() may only be called in vcl_synth
"
,
rdr
->
obj_name
);
if
((
ctx
->
method
&
(
VCL_MET_SYNTH
|
VCL_MET_BACKEND_ERROR
)
)
==
0
)
{
VRT_fail
(
ctx
,
"%s.synth() may only be called in vcl_synth
or "
"vcl_backend_error"
,
rdr
->
obj_name
);
return
;
}
...
...
src/vmod_file.vcc
View file @
86cbff7b
...
...
@@ -292,10 +292,11 @@ message.
$Method VOID .synth()
Generate a synthetic client response body from the file contents. This
method may only be called in ``vcl_synth``. Invokes VCL failure if the
most recent update check encountered an error, or if invoked in any
other VCL subroutine besides ``vcl_synth``.
Generate a synthetic response body from the file contents. This method
may only be called in ``vcl_synth`` or ``vcl_backend_error``. Invokes
VCL failure if the most recent update check encountered an error, or
if invoked in any other VCL subroutine besides the two that are
permitted.
Example::
...
...
@@ -303,6 +304,10 @@ Example::
synth_body.synth();
}
sub vcl_backend_error {
synth_body.synth();
}
$Method BLOB .blob()
Return the file's contents as a BLOB. Invokes VCL failure if the most
...
...
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