[4.1] 6f43c0e If pipe'ing, unset any existing Connection headers

PÃ¥l Hermunn Johansen hermunn at varnish-software.com
Tue Jun 6 11:36:06 CEST 2017


commit 6f43c0e9974ee61ff17a3a6bcc8487d88041a284
Author: Federico G. Schwindt <fgsch at users.noreply.github.com>
Date:   Thu Jun 1 21:02:05 2017 +0100

    If pipe'ing, unset any existing Connection headers
    
    Otherwise the backend might see multiple Connection entries.
    Fixes #2337.

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index f114284..ca6e316 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -584,7 +584,7 @@ cnt_pipe(struct worker *wrk, struct req *req)
 	HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod);
 	http_FilterReq(bo->bereq, req->http, 0);	// XXX: 0 ?
 	http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(req->vsl->wid));
-	http_SetHeader(bo->bereq, "Connection: close");
+	http_ForceHeader(bo->bereq, H_Connection, "close");
 
 	VCL_pipe_method(req->vcl, wrk, req, bo, NULL);
 
diff --git a/bin/varnishtest/tests/b00001.vtc b/bin/varnishtest/tests/b00001.vtc
index d48b9a0..b45ddb5 100644
--- a/bin/varnishtest/tests/b00001.vtc
+++ b/bin/varnishtest/tests/b00001.vtc
@@ -2,17 +2,30 @@ varnishtest "Check that a pipe transaction works"
 
 server s1 -repeat 1 {
 	rxreq
-	txresp -body "012345\n"
+	expect req.http.connection == "close"
+	txresp
+	rxreq
+	expect req.http.connection == "keep-alive"
+	txresp
 } -start
 
 varnish v1 -vcl+backend {
 	sub vcl_recv {
 		return(pipe);
 	}
+
+	sub vcl_pipe {
+		if (req.url == "/2") {
+			set bereq.http.connection = req.http.connection;
+		}
+	}
 } -start
 
 client c1 {
-	txreq -url "/"
+	txreq -url /1 -hdr "Connection: keep-alive"
+	rxresp
+	expect resp.status == 200
+	txreq -url /2 -hdr "Connection: keep-alive"
 	rxresp
 	expect resp.status == 200
 } -run



More information about the varnish-commit mailing list