Sessions rework
This commit is contained in:
parent
3e85da2afd
commit
074e757028
27 changed files with 1222 additions and 1183 deletions
|
@ -55,7 +55,6 @@ namespace Mist{
|
|||
}
|
||||
|
||||
void HTTPOutput::onFail(const std::string &msg, bool critical){
|
||||
INFO_MSG("Failing '%s': %s", H.url.c_str(), msg.c_str());
|
||||
if (!webSock && !isRecording() && !responded){
|
||||
H.Clean(); // make sure no parts of old requests are left in any buffers
|
||||
H.SetHeader("Server", APPIDENT);
|
||||
|
@ -238,18 +237,6 @@ namespace Mist{
|
|||
}
|
||||
/*LTS-END*/
|
||||
if (H.hasHeader("User-Agent")){UA = H.GetHeader("User-Agent");}
|
||||
if (hasSessionIDs()){
|
||||
if (H.GetVar("sessId").size()){
|
||||
std::string ua = H.GetVar("sessId");
|
||||
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||
}else{
|
||||
std::string ua = JSON::Value(getpid()).asString();
|
||||
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||
}
|
||||
}else{
|
||||
std::string mixed_ua = UA + H.GetHeader("X-Playback-Session-Id");
|
||||
crc = checksum::crc32(0, mixed_ua.data(), mixed_ua.size());
|
||||
}
|
||||
|
||||
if (H.GetVar("audio") != ""){targetParams["audio"] = H.GetVar("audio");}
|
||||
if (H.GetVar("video") != ""){targetParams["video"] = H.GetVar("video");}
|
||||
|
@ -281,6 +268,21 @@ namespace Mist{
|
|||
realTime = 0;
|
||||
}
|
||||
}
|
||||
// Get session ID cookie or generate a random one if it wasn't set
|
||||
if (!sid.size()){
|
||||
std::map<std::string, std::string> storage;
|
||||
const std::string koekjes = H.GetHeader("Cookie");
|
||||
HTTP::parseVars(koekjes, storage);
|
||||
if (storage.count("sid")){
|
||||
// Get sid cookie, which is used to divide connections into sessions
|
||||
sid = storage.at("sid");
|
||||
}else{
|
||||
// Else generate one
|
||||
const std::string newSid = UA + JSON::Value(getpid()).asString();
|
||||
sid = JSON::Value(checksum::crc32(0, newSid.data(), newSid.size())).asString();
|
||||
H.SetHeader("sid", sid.c_str());
|
||||
}
|
||||
}
|
||||
// Handle upgrade to websocket if the output supports it
|
||||
std::string upgradeHeader = H.GetHeader("Upgrade");
|
||||
Util::stringToLower(upgradeHeader);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue