Commit f07287a6 authored by Brandon Black's avatar Brandon Black Committed by Pål Hermunn Johansen

Correctly handle HTTP/1.1 EOF response

Commit e142a199 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
parent 55a08f55
...@@ -307,7 +307,7 @@ http1_body_status(const struct http *hp, struct http_conn *htc, int request) ...@@ -307,7 +307,7 @@ http1_body_status(const struct http *hp, struct http_conn *htc, int request)
return (cl == 0 ? BS_NONE : BS_LENGTH); 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); return (BS_NONE);
if (http_HdrIs(hp, H_Connection, "keep-alive")) { if (http_HdrIs(hp, H_Connection, "keep-alive")) {
......
...@@ -3,19 +3,15 @@ varnishtest "Check EOF responses work with HTTP/1.1" ...@@ -3,19 +3,15 @@ varnishtest "Check EOF responses work with HTTP/1.1"
server s1 { server s1 {
rxreq rxreq
txresp -nolen -bodylen 10 txresp -nolen -bodylen 10
rxreq close
txresp -hdr "Connection: close" -nolen -bodylen 10 accept
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
} -start } -start
client c1 { client c1 {
txreq -url /1 txreq
rxresp
expect resp.status == 200
expect resp.bodylen == 0
txreq -url /2
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
expect resp.bodylen == 10 expect resp.bodylen == 10
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment