Fixed websockets in IE11. Bleep you, MS. -_-

This commit is contained in:
Thulinma 2019-06-19 10:44:03 +02:00
parent d6ad8f9811
commit 128f30bfb6
3 changed files with 16 additions and 6 deletions

View file

@ -11,15 +11,19 @@ namespace HTTP{
Websocket::Websocket(Socket::Connection &c, HTTP::Parser &h) : C(c), H(h){ Websocket::Websocket(Socket::Connection &c, HTTP::Parser &h) : C(c), H(h){
frameType = 0; frameType = 0;
if (H.GetHeader("Connection").find("Upgrade") == std::string::npos){ std::string connHeader = H.GetHeader("Connection");
Util::stringToLower(connHeader);
if (connHeader.find("upgrade") == std::string::npos){
FAIL_MSG("Could not negotiate websocket, connection header incorrect (%s).", FAIL_MSG("Could not negotiate websocket, connection header incorrect (%s).",
H.GetHeader("Connection").c_str()); connHeader.c_str());
C.close(); C.close();
return; return;
} }
if (H.GetHeader("Upgrade") != "websocket"){ std::string upgradeHeader = H.GetHeader("Upgrade");
Util::stringToLower(upgradeHeader);
if (upgradeHeader != "websocket"){
FAIL_MSG("Could not negotiate websocket, upgrade header incorrect (%s).", FAIL_MSG("Could not negotiate websocket, upgrade header incorrect (%s).",
H.GetHeader("Upgrade").c_str()); upgradeHeader.c_str());
C.close(); C.close();
return; return;
} }

View file

@ -208,6 +208,8 @@ namespace Mist {
myConn.close(); myConn.close();
return; return;
} }
std::string connHeader = H.GetHeader("Connection");
Util::stringToLower(connHeader);
if (handler != capa["name"].asStringRef() || H.GetVar("stream") != streamName){ if (handler != capa["name"].asStringRef() || H.GetVar("stream") != streamName){
MEDIUM_MSG("Switching from %s (%s) to %s (%s)", capa["name"].asStringRef().c_str(), streamName.c_str(), handler.c_str(), H.GetVar("stream").c_str()); MEDIUM_MSG("Switching from %s (%s) to %s (%s)", capa["name"].asStringRef().c_str(), streamName.c_str(), handler.c_str(), H.GetVar("stream").c_str());
streamName = H.GetVar("stream"); streamName = H.GetVar("stream");
@ -238,7 +240,9 @@ namespace Mist {
if (H.GetVar("video") != ""){targetParams["video"] = H.GetVar("video");} if (H.GetVar("video") != ""){targetParams["video"] = H.GetVar("video");}
if (H.GetVar("subtitle") != ""){targetParams["subtitle"] = H.GetVar("subtitle");} if (H.GetVar("subtitle") != ""){targetParams["subtitle"] = H.GetVar("subtitle");}
//Handle upgrade to websocket if the output supports it //Handle upgrade to websocket if the output supports it
if (doesWebsockets() && H.GetHeader("Upgrade") == "websocket"){ std::string upgradeHeader = H.GetHeader("Upgrade");
Util::stringToLower(upgradeHeader);
if (doesWebsockets() && upgradeHeader == "websocket"){
INFO_MSG("Switching to Websocket mode"); INFO_MSG("Switching to Websocket mode");
setBlocking(false); setBlocking(false);
preWebsocketConnect(); preWebsocketConnect();

View file

@ -783,7 +783,9 @@ namespace Mist {
if (!useragent.size()){ if (!useragent.size()){
useragent = H.GetHeader("User-Agent"); useragent = H.GetHeader("User-Agent");
} }
if (H.GetHeader("Upgrade") != "websocket"){return false;} std::string upgradeHeader = H.GetHeader("Upgrade");
Util::stringToLower(upgradeHeader);
if (upgradeHeader != "websocket"){return false;}
HTTP::Websocket ws(myConn, H); HTTP::Websocket ws(myConn, H);
if (!ws){return false;} if (!ws){return false;}
setBlocking(false); setBlocking(false);