[6.0] 4e5728c5c Add coverage for Keep-Alive header removal

Martin Blix Grydeland martin at varnish-software.com
Tue Nov 8 10:03:08 UTC 2022


commit 4e5728c5cc3d4242856e76f4eec1da5a6617ee3f
Author: AlveElde <alve_elde at hotmail.com>
Date:   Wed Sep 28 14:53:20 2022 +0200

    Add coverage for Keep-Alive header removal

diff --git a/bin/varnishtest/tests/b00080.vtc b/bin/varnishtest/tests/b00080.vtc
new file mode 100644
index 000000000..d1227f1be
--- /dev/null
+++ b/bin/varnishtest/tests/b00080.vtc
@@ -0,0 +1,77 @@
+varnishtest "Keep-Alive is a hop-by-hop header"
+
+server s1 {
+	rxreq
+	expect req.http.req-keep-alive == "true"
+	expect req.http.bereq-keep-alive == "false"
+	expect req.http.Keep-Alive == <undef>
+	txresp -hdr "Keep-Alive: 1"
+
+	rxreq
+	expect req.http.req-keep-alive == "true"
+	expect req.http.bereq-keep-alive == "false"
+	expect req.http.Keep-Alive == <undef>
+	txresp -hdr "Connection: Keep-Alive" -hdr "Keep-Alive: 2"
+
+	rxreq
+	expect req.http.req-keep-alive == "true"
+	expect req.http.bereq-keep-alive == "false"
+	expect req.http.Keep-Alive == <undef>
+	expect req.http.Cookie == "3"
+	txresp -hdr "Keep-Alive: 3"
+
+	rxreq
+	expect req.http.req-keep-alive == "true"
+	expect req.http.bereq-keep-alive == "false"
+	expect req.http.Keep-Alive == <undef>
+	expect req.http.Cookie == "4"
+	txresp -hdr "Connection: Keep-Alive" -hdr "Keep-Alive: 4"
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		set req.http.req-keep-alive = !(!req.http.Keep-Alive);
+	}
+
+	sub vcl_backend_fetch {
+		set bereq.http.bereq-keep-alive = !(!bereq.http.Keep-Alive);
+	}
+
+	sub vcl_backend_response {
+		set beresp.http.beresp-keep-alive = !(!beresp.http.Keep-Alive);
+	}
+
+	sub vcl_deliver {
+		set resp.http.resp-keep-alive = !(!resp.http.Keep-Alive);
+	}
+} -start
+
+client c1 {
+	txreq -url "/1" -hdr "Keep-Alive: 1"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.beresp-keep-alive == "true"
+	expect resp.http.resp-keep-alive == "false"
+	expect resp.http.Keep-Alive == <undef>
+
+	txreq -url "/2" -hdr "Connection: Keep-Alive" -hdr "Keep-Alive: 2"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.beresp-keep-alive == "true"
+	expect resp.http.resp-keep-alive == "false"
+	expect req.http.Keep-Alive == <undef>
+
+	txreq -url "/3" -hdr "Keep-Alive: 3" -hdr "Cookie: 3"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.beresp-keep-alive == "true"
+	expect resp.http.resp-keep-alive == "false"
+	expect resp.http.Keep-Alive == <undef>
+
+	txreq -url "/4" -hdr "Connection: Keep-Alive" -hdr "Keep-Alive: 4" -hdr "Cookie: 4"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.beresp-keep-alive == "true"
+	expect resp.http.resp-keep-alive == "false"
+	expect req.http.Keep-Alive == <undef>
+} -run


More information about the varnish-commit mailing list