From 66c518949d78c7fd9fd778204aaa2426af4d9858 Mon Sep 17 00:00:00 2001 From: antao Date: Fri, 5 Apr 2019 13:33:02 +0800 Subject: [PATCH] Make WebSocket suitable for Firefox browser --- lib/src/HttpServer.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/HttpServer.cc b/lib/src/HttpServer.cc index d334c7af..bd48df85 100755 --- a/lib/src/HttpServer.cc +++ b/lib/src/HttpServer.cc @@ -103,7 +103,10 @@ static bool parseWebsockMessage(MsgBuffer *buffer, std::string &message) static bool isWebSocket(const HttpRequestImplPtr &req) { - if (req->getHeaderBy("connection") == "Upgrade" && + auto &headers = req->headers(); + if (headers.find("upgrade") == headers.end() || headers.find("connection") == headers.end()) + return false; + if (req->getHeaderBy("connection").find("Upgrade") != std::string::npos && req->getHeaderBy("upgrade") == "websocket") { LOG_TRACE << "new websocket request";