[master] 5f1fab0 Now that it's clear there won't be a HTTP/1.2, and that HTTP/2.0 is an entirely different protocol, tighten up the version checks correspondingly.

Poul-Henning Kamp phk at FreeBSD.org
Thu Apr 30 12:57:10 CEST 2015


commit 5f1fab09409f6919fd227f726b7ad0bac9577a14
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Apr 30 10:55:13 2015 +0000

    Now that it's clear there won't be a HTTP/1.2, and that HTTP/2.0
    is an entirely different protocol, tighten up the version checks
    correspondingly.
    
    Also reject HTTP variants prior to HTTP/1.0.

diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index bd8d4b1..bdfdf0d 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -641,7 +641,7 @@ http_DoConnection(struct http *hp)
 	enum sess_close retval;
 	unsigned u, v;
 
-	if (hp->protover < 11)
+	if (hp->protover == 10)
 		retval = SC_REQ_HTTP10;
 	else
 		retval = SC_NULL;
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index c0eaeca..5db8754 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -131,7 +131,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 		req->res_mode |= RES_LEN;
 
 	if (req->wantbody && !(req->res_mode & RES_LEN)) {
-		if (req->http->protover >= 11) {
+		if (req->http->protover == 11) {
 			req->res_mode |= RES_CHUNKED;
 			http_SetHeader(req->resp, "Transfer-Encoding: chunked");
 		} else {
diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c
index c99ec30..29110fb 100644
--- a/bin/varnishd/http1/cache_http1_proto.c
+++ b/bin/varnishd/http1/cache_http1_proto.c
@@ -325,7 +325,7 @@ http1_proto_ver(struct http *hp)
 	else if (!strcasecmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1"))
 		hp->protover = 11;
 	else
-		hp->protover = 9;
+		hp->protover = 0;
 }
 
 /*--------------------------------------------------------------------*/
@@ -344,6 +344,8 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp)
 	if (retval != 0)
 		return (retval);
 	http1_proto_ver(hp);
+	if (hp->protover == 0)
+		return (400);
 
 	if (http_CountHdr(hp, H_Host) > 1)
 		return (400);
@@ -399,7 +401,7 @@ HTTP1_DissectResponse(struct http *hp, struct http_conn *htc)
 
 	if (retval == 0) {
 		http1_proto_ver(hp);
-		if (hp->protover != 10 && hp->protover != 11)
+		if (hp->protover == 0)
 			retval = 503;
 	}
 
diff --git a/bin/varnishtest/tests/e00012.vtc b/bin/varnishtest/tests/e00012.vtc
index cb0a9e4..8ee2eca 100644
--- a/bin/varnishtest/tests/e00012.vtc
+++ b/bin/varnishtest/tests/e00012.vtc
@@ -36,10 +36,4 @@ client c1 {
 	expect resp.bodylen == 67
 } -run
 
-client c1 {
-	txreq -url /foo/bar -proto ""
-	rxresp
-	expect resp.status == 200
-	expect resp.bodylen == 67
-} -run
 varnish v1 -expect esi_errors == 0



More information about the varnish-commit mailing list