]> 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)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sun, 23 Jun 2019 11:44:59 +0000 (11:44 +0000)
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 9edfa7eb751d1ab441b8665ec78d3b5efd34555e..3650961bbf62ec0be82d47cafd228e64c1d7aa3f 100644 (file)
@@ -1926,10 +1926,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 b6d87a2e9818e7e912b9066e29a22eb0886d990a..c6f2fb0d2b986235c810a9a8d425816bca2ccee9 100644 (file)
@@ -16,7 +16,7 @@ class StateFlags
 {
 public:
     unsigned int front_end_https = 0; ///< send "Front-End-Https: On" header (off/on/auto=2)
-    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;