[master] 0953ac1 Make req reachable from the pipe code

Federico G. Schwindt fgsch at lodoss.net
Tue Jul 5 12:10:09 CEST 2016


commit 0953ac17aa3594933aac61a80bdd02ebfb903654
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Mon Jul 4 17:17:16 2016 +0100

    Make req reachable from the pipe code
    
    We will need it if the body was consumed due to a call to
    std.cache_req_body (VRB_Cache).
    
    Analysis and test by daghf.
    
    Fixes #1881.

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index f92c85b..fa9d8f6 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -573,6 +573,9 @@ cnt_pipe(struct worker *wrk, struct req *req)
 		nxt = REQ_FSM_MORE;
 		break;
 	case VCL_RET_PIPE:
+		AZ(bo->req);
+		bo->req = req;
+		bo->wrk = wrk;
 		SES_Close(req->sp, VDI_Http1Pipe(req, bo));
 		nxt = REQ_FSM_DONE;
 		break;
diff --git a/bin/varnishtest/tests/r01881.vtc b/bin/varnishtest/tests/r01881.vtc
new file mode 100644
index 0000000..5c3ab4d
--- /dev/null
+++ b/bin/varnishtest/tests/r01881.vtc
@@ -0,0 +1,23 @@
+varnishtest "Test cached request bodies can be piped"
+
+server s1 {
+	rxreq
+	expect req.bodylen == 6
+	expect req.http.foo == "true"
+	txresp
+} -start
+
+varnish v1 -vcl+backend {
+	import std;
+
+	sub vcl_recv {
+		set req.http.foo = std.cache_req_body(10KB);
+		return (pipe);
+	}
+} -start
+
+client c1 {
+	txreq -body "foobar"
+	rxresp
+	expect resp.status == 200
+} -run



More information about the varnish-commit mailing list