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
4d3baa90
Commit
4d3baa90
authored
Jan 03, 2017
by
Dridi Boukelmoune
Committed by
guillaume quintard
Jan 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write a request or response body from a stream too
parent
73d44e8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
a02024.vtc
bin/varnishtest/tests/a02024.vtc
+27
-0
vtc_http2.c
bin/varnishtest/vtc_http2.c
+24
-0
No files found.
bin/varnishtest/tests/a02024.vtc
0 → 100644
View file @
4d3baa90
varnishtest "Write a body to a file"
server s1 {
fatal
stream 1 {
rxreq
expect req.http.Content-Type == "text/plain"
write_body req.txt
txresp -hdr Content-Type text/plain -body response
} -run
} -start
client c1 -connect ${s1_sock} {
fatal
stream 1 {
txreq -req POST -hdr Content-Type text/plain -body request
rxresp
expect resp.http.Content-Type == "text/plain"
write_body resp.txt
} -run
} -run
server s1 -wait
shell {grep -q request req.txt}
shell {grep -q response resp.txt}
bin/varnishtest/vtc_http2.c
View file @
4d3baa90
...
...
@@ -45,6 +45,7 @@
#include "vtc_http.h"
#include "vct.h"
#include "vfil.h"
#include "vgz.h"
#include "vnum.h"
#include "vre.h"
...
...
@@ -2467,6 +2468,28 @@ cmd_expect(CMD_ARGS)
AZ
(
pthread_mutex_unlock
(
&
s
->
hp
->
mtx
));
}
/* SECTION: stream.spec.write_body
*
* write_body STRING
* Same as the ``write_body`` command for HTTP/1.
*/
static
void
cmd_write_body
(
CMD_ARGS
)
{
struct
stream
*
s
;
(
void
)
cmd
;
(
void
)
vl
;
CAST_OBJ_NOTNULL
(
s
,
priv
,
STREAM_MAGIC
);
AN
(
av
[
0
]);
AN
(
av
[
1
]);
AZ
(
av
[
2
]);
AZ
(
strcmp
(
av
[
0
],
"write_body"
));
if
(
VFIL_writefile
(
NULL
,
av
[
1
],
s
->
body
,
s
->
bodylen
)
!=
0
)
vtc_log
(
s
->
hp
->
vl
,
0
,
"failed to write body: %s (%d)"
,
strerror
(
errno
),
errno
);
}
/* SECTION: stream.spec Specification
*
* The specification of a stream follows the exact same rules as one for a
...
...
@@ -2502,6 +2525,7 @@ static const struct cmds stream_cmds[] = {
CMD_STREAM
(
txrst
)
CMD_STREAM
(
txsettings
)
CMD_STREAM
(
txwinup
)
CMD_STREAM
(
write_body
)
/* general purpose */
CMD
(
barrier
)
...
...
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