[4.1] f07287a Correctly handle HTTP/1.1 EOF response

PÃ¥l Hermunn Johansen hermunn at varnish-software.com
Fri Jun 3 17:05:07 CEST 2016


commit f07287a6a3a5ebe797346e97ff0b464df5b07a3e
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 67d7b2b..ebf0d2a 100644
--- a/bin/varnishd/http1/cache_http1_proto.c
+++ b/bin/varnishd/http1/cache_http1_proto.c
@@ -307,7 +307,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