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
d424a373
Commit
d424a373
authored
Jan 02, 2017
by
Dridi Boukelmoune
Committed by
guillaume quintard
Jan 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a varnishtest command to write a body to a file
parent
35b17acf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
a00015.vtc
bin/varnishtest/tests/a00015.vtc
+20
-0
vtc_http.c
bin/varnishtest/vtc_http.c
+27
-0
No files found.
bin/varnishtest/tests/a00015.vtc
0 → 100644
View file @
d424a373
varnishtest "Write a body to a file"
server s1 {
rxreq
expect req.http.Content-Type == "text/plain"
write_body req.txt
txresp -hdr "Content-Type: text/plain" -body response
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -req POST -hdr "Content-Type: text/plain" -body request
rxresp
expect resp.http.Content-Type == "text/plain"
write_body resp.txt
} -run
shell {grep -q request req.txt}
shell {grep -q response resp.txt}
bin/varnishtest/vtc_http.c
View file @
d424a373
...
...
@@ -43,6 +43,7 @@
#include "vtc_http.h"
#include "vct.h"
#include "vfil.h"
#include "vgz.h"
#include "vnum.h"
#include "vre.h"
...
...
@@ -1776,6 +1777,31 @@ cmd_http_stream(CMD_ARGS)
cmd_stream
(
av
,
hp
,
cmd
,
vl
);
}
/* SECTION: client-server.spec.write_body
*
* write_body STRING
* Write the body of a request or a response to a file. By using the
* shell or err_shell commands, higher-level checks on the body can
* be performed (eg. XML, JSON, ...) provided that such checks can be
* delegated to an external program.
*/
static
void
cmd_http_write_body
(
CMD_ARGS
)
{
struct
http
*
hp
;
(
void
)
cmd
;
(
void
)
vl
;
CAST_OBJ_NOTNULL
(
hp
,
priv
,
HTTP_MAGIC
);
AN
(
av
[
0
]);
AN
(
av
[
1
]);
AZ
(
av
[
2
]);
AZ
(
strcmp
(
av
[
0
],
"write_body"
));
if
(
VFIL_writefile
(
NULL
,
av
[
1
],
hp
->
body
,
hp
->
bodyl
)
!=
0
)
vtc_log
(
hp
->
vl
,
0
,
"failed to write body: %s (%d)"
,
strerror
(
errno
),
errno
);
}
/**********************************************************************
* Execute HTTP specifications
*/
...
...
@@ -1801,6 +1827,7 @@ static const struct cmds http_cmds[] = {
/* body */
CMD_HTTP
(
gunzip
),
CMD_HTTP
(
write_body
),
/* HTTP/1.x */
CMD_HTTP
(
chunked
),
...
...
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