[master] ad0b902 Always use HTTP/1.1 on backend connections for pass & fetch

Nils Goroll nils.goroll at uplex.de
Mon Feb 26 13:27:06 UTC 2018


commit ad0b902e5d02052c11a1ba9c5649a2e807faab65
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Feb 26 14:24:41 2018 +0100

    Always use HTTP/1.1 on backend connections for pass & fetch
    
    pipe remains the only exception.
    
    Ref: https://tools.ietf.org/html/rfc7230#section-2.6
    
       Intermediaries that process HTTP messages (i.e., all intermediaries
       other than those acting as tunnels) MUST send their own HTTP-version
       in forwarded messages.
    
    Closes #2574

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index d5e2548..581a707 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -179,16 +179,14 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo)
 	http_FilterReq(bo->bereq0, bo->req->http,
 	    bo->do_pass ? HTTPH_R_PASS : HTTPH_R_FETCH);
 
-	if (!bo->do_pass) {
+	if (bo->do_pass)
+		AZ(bo->stale_oc);
+	else {
 		http_ForceField(bo->bereq0, HTTP_HDR_METHOD, "GET");
-		http_ForceField(bo->bereq0, HTTP_HDR_PROTO, "HTTP/1.1");
 		if (cache_param->http_gzip_support)
 			http_ForceHeader(bo->bereq0, H_Accept_Encoding, "gzip");
-	} else {
-		AZ(bo->stale_oc);
-		if (bo->bereq0->protover > 11)
-			http_ForceField(bo->bereq0, HTTP_HDR_PROTO, "HTTP/1.1");
 	}
+	http_ForceField(bo->bereq0, HTTP_HDR_PROTO, "HTTP/1.1");
 	http_CopyHome(bo->bereq0);
 
 	if (bo->stale_oc != NULL &&
diff --git a/bin/varnishtest/tests/b00001.vtc b/bin/varnishtest/tests/b00001.vtc
index 95dc08d..3a07e5e 100644
--- a/bin/varnishtest/tests/b00001.vtc
+++ b/bin/varnishtest/tests/b00001.vtc
@@ -2,9 +2,11 @@ varnishtest "Check that a pipe transaction works"
 
 server s1 -repeat 1 {
 	rxreq
+	expect req.proto == "HTTP/1.0"
 	expect req.http.connection == "close"
 	txresp
 	rxreq
+	expect req.proto == "nonsense"
 	expect req.http.connection == "keep-alive"
 	txresp
 } -start
@@ -22,10 +24,10 @@ varnish v1 -vcl+backend {
 } -start
 
 client c1 {
-	txreq -url /1 -hdr "Connection: keep-alive"
+	txreq -proto HTTP/1.0 -url /1 -hdr "Connection: keep-alive"
 	rxresp
 	expect resp.status == 200
-	txreq -url /2 -hdr "Connection: keep-alive"
+	txreq -proto nonsense -url /2 -hdr "Connection: keep-alive"
 	rxresp
 	expect resp.status == 200
 } -run
diff --git a/bin/varnishtest/tests/b00002.vtc b/bin/varnishtest/tests/b00002.vtc
index 26591b0..2c978ee 100644
--- a/bin/varnishtest/tests/b00002.vtc
+++ b/bin/varnishtest/tests/b00002.vtc
@@ -2,6 +2,7 @@ varnishtest "Check that a pass transaction works"
 
 server s1 {
 	rxreq
+	expect req.proto == HTTP/1.1
 	txresp -hdr "Cache-Control: max-age=120" -hdr "Connection: close" -body "012345\n"
 } -start
 
@@ -25,9 +26,11 @@ logexpect l1 -v v1 -g request {
 } -start
 
 client c1 {
-	txreq -url "/"
+	txreq -proto HTTP/1.0 -url "/"
 	rxresp
+	expect resp.proto == HTTP/1.1
 	expect resp.status == 200
+	expect resp.http.connection == close
 	expect resp.http.x-ttl == 0.000
 } -run
 
diff --git a/bin/varnishtest/tests/r01662.vtc b/bin/varnishtest/tests/r01662.vtc
index d8eb01c..1a19339 100644
--- a/bin/varnishtest/tests/r01662.vtc
+++ b/bin/varnishtest/tests/r01662.vtc
@@ -14,7 +14,7 @@ logexpect l1 -v v1 -g request {
 	expect * 1001	ReqMethod	"HEAD"
 	expect * =	ReqProtocol	"HTTP/1.0"
 	expect * 1002	BereqMethod	"GET"
-	expect 0 =	BereqProtocol	"HTTP/1.1"
+	expect 1 =	BereqProtocol	"HTTP/1.1"
 } -start
 
 client c1 {


More information about the varnish-commit mailing list