]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not send keep-alive in 101 (Switching Protocols) responses (#709)
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 10 Aug 2020 18:46:02 +0000 (18:46 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 12 Aug 2020 18:48:38 +0000 (18:48 +0000)
... because it breaks clients using websocket_client[1] library and is
redundant in our HTTP/1.1 control messages anyway.

I suspect that at least some buggy clients are confused by a multi-value
Connection field rather than the redundant keep-alive signal itself, but
let's try to follow RFC 7230 Upgrade example more closely this time and
send no keep-alive at all.

[1] https://pypi.org/project/websocket_client/

src/servers/Http1Server.cc

index 8a9439bb6543698f1265a0d43b4a77bcecd2ca54..c457ba245c9b565426cb926674cd89101378a4d4 100644 (file)
@@ -360,7 +360,8 @@ Http::One::Server::writeControlMsgAndCall(HttpReply *rep, AsyncCall::Pointer &ca
 
     if (switching && /* paranoid: */ upgradeHeader.size()) {
         rep->header.putStr(Http::HdrType::UPGRADE, upgradeHeader.termedBuf());
-        rep->header.putStr(Http::HdrType::CONNECTION, "upgrade, keep-alive");
+        rep->header.putStr(Http::HdrType::CONNECTION, "upgrade");
+        // keep-alive is redundant, breaks some 101 (Switching Protocols) recipients
     } else {
         rep->header.putStr(Http::HdrType::CONNECTION, "keep-alive");
     }