Merge pull request #110 from an-tao/dev

Make WebSocket suitable for Firefox browser
This commit is contained in:
An Tao 2019-04-05 13:55:34 +08:00 committed by GitHub
commit dc07451ddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -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";