]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Send Connection:close with the known-last request on a connection (#421)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Fri, 21 Jun 2019 13:03:30 +0000 (13:03 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Thu, 4 Jul 2019 11:01:16 +0000 (23:01 +1200)
Squid did not send Connection:close request header on a to-be-closed
HTTP/1.1 connection, violating RFC 7230 Section 6.6 "SHOULD send"
requirement.

src/http.cc
src/http/StateFlags.h

index 51ea464f87f474b3bbbcb78b4e26d5c6d62b4d12..6243b491016905cf20feed308230eeb329ce9168 100644 (file)
@@ -1909,10 +1909,10 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
         delete cc;
     }
 
-    /* maybe append Connection: keep-alive */
-    if (flags.keepalive) {
-        hdr_out->putStr(Http::HdrType::CONNECTION, "keep-alive");
-    }
+    // Always send Connection because HTTP/1.0 servers need explicit "keep-alive"
+    // while HTTP/1.1 servers need explicit "close", and we do not always know
+    // the server expectations.
+    hdr_out->putStr(Http::HdrType::CONNECTION, flags.keepalive ? "keep-alive" : "close");
 
     /* append Front-End-Https */
     if (flags.front_end_https) {
index cb7cc90fca931ffe2bbe3ec93361c8eece0ff3e8..b0722d3a1c3722b2b07ebda0ac0bf758a0ad2ba1 100644 (file)
@@ -17,7 +17,7 @@ class StateFlags
 public:
     unsigned int front_end_https = 0; ///< send "Front-End-Https: On" header (off/on/auto=2)
     bool proxying = false;
-    bool keepalive = false;
+    bool keepalive = false; ///< whether to keep the connection persistent
     bool only_if_cached = false;
     bool handling1xx = false;       ///< we are ignoring or forwarding 1xx response
     bool headers_parsed = false;