[master] cbaf1c3f2 resp: Don't overwrite Via headers

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Aug 5 09:24:08 UTC 2022


commit cbaf1c3f270b8d2e1ae0356d6c3a17fcccd97b0d
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Jul 26 11:04:41 2022 +0200

    resp: Don't overwrite Via headers
    
    The order for Via entries follows the response return path, from the
    furthest proxy to the closest.
    
    Refs #3794

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index c23270073..89b585306 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -167,7 +167,7 @@ Resp_Setup_Deliver(struct req *req)
 	http_PrintfHeader(h, "Age: %.0f",
 	    floor(fmax(0., req->t_prev - oc->t_origin)));
 
-	http_SetHeader(h, "Via: 1.1 varnish (Varnish/" PACKAGE_BRANCH ")");
+	http_AppendHeader(h, H_Via, "1.1 varnish (Varnish/" PACKAGE_BRANCH ")");
 
 	if (cache_param->http_gzip_support &&
 	    ObjCheckFlag(req->wrk, oc, OF_GZIPED) &&
diff --git a/bin/varnishtest/tests/r03794.vtc b/bin/varnishtest/tests/r03794.vtc
new file mode 100644
index 000000000..7535b0593
--- /dev/null
+++ b/bin/varnishtest/tests/r03794.vtc
@@ -0,0 +1,21 @@
+varnishtest "Append Via header"
+
+server s1 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -vcl+backend "" -start
+
+varnish v2 -vcl {
+	backend v1 {
+		.host = "${v1_sock}";
+	}
+} -start
+
+client c1 -connect ${v2_sock} {
+	txreq
+	rxresp
+	expect resp.http.via == \
+		"1.1 varnish (Varnish/${pkg_branch}), 1.1 varnish (Varnish/${pkg_branch})"
+} -run


More information about the varnish-commit mailing list