Fixed websockets in IE11. Bleep you, MS. -_-
This commit is contained in:
parent
29c8205e79
commit
d41b207cc5
3 changed files with 16 additions and 6 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,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");
|
||||||
|
@ -265,7 +267,9 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//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();
|
||||||
|
|
|
@ -857,7 +857,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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue