[master] 7e90a2b Correctly handle HTTP/1.1 EOF response

Federico G. Schwindt fgsch at lodoss.net
Tue May 24 00:31:06 CEST 2016


commit 7e90a2b4d47c16209065a70c801a7dbf4844b60a
Author: Brandon Black <bblack at wikimedia.org>
Date:   Tue May 17 21:37:31 2016 +0000

    Correctly handle HTTP/1.1 EOF response
    
    Commit e142a199c for Issue #1918 fixed up the case where the
    server sends an HTTP/1.1 response with no Content-Length, no
    Transfer-Encoding, but with Connection:close.
    
    This fixes the very similar case where all the conditions are the
    same except that there's also no Connection: close header, but the
    content is still implicitly delimited by the server closing the
    connection.
    
    This behavior has been observed from multiple versions of Apache
    with WSGI applications behind it, resulting in broken
    Content-Length:0 responses from Varnish.
    
    Ref: varnishcache/varnish-cache#1954

diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c
index 713a8d6..f5dbe53 100644
--- a/bin/varnishd/http1/cache_http1_proto.c
+++ b/bin/varnishd/http1/cache_http1_proto.c
@@ -301,7 +301,7 @@ http1_body_status(const struct http *hp, struct http_conn *htc, int request)
 		return (cl == 0 ? BS_NONE : BS_LENGTH);
 	}
 
-	if (hp->protover == 11 && (request || !http_HdrIs(hp, H_Connection, "close")))
+	if (hp->protover == 11 && request)
 		return (BS_NONE);
 
 	if (http_HdrIs(hp, H_Connection, "keep-alive")) {
diff --git a/bin/varnishtest/tests/r01918.vtc b/bin/varnishtest/tests/r01918.vtc
index c0593aa..68a4d72 100644
--- a/bin/varnishtest/tests/r01918.vtc
+++ b/bin/varnishtest/tests/r01918.vtc
@@ -3,19 +3,15 @@ varnishtest "Check EOF responses work with HTTP/1.1"
 server s1 {
 	rxreq
 	txresp -nolen -bodylen 10
-	rxreq
-	txresp -hdr "Connection: close" -nolen -bodylen 10
+	close
+	accept
 } -start
 
 varnish v1 -vcl+backend {
 } -start
 
 client c1 {
-	txreq -url /1
-	rxresp
-	expect resp.status == 200
-	expect resp.bodylen == 0
-	txreq -url /2
+	txreq
 	rxresp
 	expect resp.status == 200
 	expect resp.bodylen == 10



More information about the varnish-commit mailing list