Updated CORS headers and the (HTTP) output protocols to work with it.

This commit is contained in:
Erik Zandvliet 2016-01-26 14:34:14 +01:00
parent 3f93ca5f82
commit 1866e4e1e1
4 changed files with 39 additions and 10 deletions

View file

@ -536,26 +536,23 @@ namespace Mist {
}
void OutDashMP4::onHTTP(){
std::string method = H.method;
initialize();
if (myMeta.live){
updateMeta();
}
std::string url = H.url;
if (H.method == "OPTIONS"){
H.Clean();
H.SetHeader("Content-Type", "application/octet-stream");
H.SetHeader("Cache-Control", "no-cache");
H.setCORSHeaders();
H.SetBody("");
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
if (url.find(".mpd") != std::string::npos){
H.Clean();
H.SetHeader("Content-Type", "application/xml");
H.SetHeader("Cache-Control", "no-cache");
H.setCORSHeaders();
if(method == "OPTIONS" || method == "HEAD"){
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
H.SetBody(buildManifest());
H.SendResponse("200", "OK", myConn);
DEVEL_MSG("Manifest sent");
@ -569,6 +566,11 @@ namespace Mist {
H.SetHeader("Content-Type", "video/mp4");
H.SetHeader("Cache-Control", "no-cache");
H.setCORSHeaders();
if(method == "OPTIONS" || method == "HEAD"){
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
H.StartResponse(H, myConn);
if (url.find("init.m4s") != std::string::npos){

View file

@ -217,8 +217,15 @@ namespace Mist {
if (H.GetVar("s").size() && H.GetVar("s") == SUPER_SECRET){
H.Clean();
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
H.setCORSHeaders();
if(method == "OPTIONS" || method == "HEAD"){
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
H.SetBody("Yup");
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
/*LTS-END*/

View file

@ -27,6 +27,7 @@ namespace Mist {
}
void OutHTTPMinimalServer::onHTTP(){
std::string method = H.method;
//determine actual file path for the request
std::string path = resolved_path + H.url.substr(8);
@ -45,6 +46,11 @@ namespace Mist {
}
H.Clean();
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
H.setCORSHeaders();
if(method == "OPTIONS" || method == "HEAD"){
H.SendResponse("200", "OK", myConn);
return;
}
H.SetBody("File not found");
H.SendResponse("404", "OK", myConn);
return;
@ -59,6 +65,12 @@ namespace Mist {
H.Clean();
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
H.SetHeader("Content-Length", filesize);
H.setCORSHeaders();
if(method == "OPTIONS" || method == "HEAD"){
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
H.SendResponse("200", "OK", myConn);
while (inFile.good()){
inFile.read(buffer, 4096);

View file

@ -27,9 +27,17 @@ namespace Mist {
}
void OutHTTPTS::onHTTP(){
std::string method = H.method;
initialize();
H.Clean();
H.SetHeader("Content-Type", "video/mp2t");
H.setCORSHeaders();
if(method == "OPTIONS" || method == "HEAD"){
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
H.StartResponse(H, myConn);
parseData = true;
wantRequest = false;