Updated CORS headers and the (HTTP) output protocols to work with it.
This commit is contained in:
parent
3f93ca5f82
commit
1866e4e1e1
4 changed files with 39 additions and 10 deletions
|
@ -536,26 +536,23 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutDashMP4::onHTTP(){
|
void OutDashMP4::onHTTP(){
|
||||||
|
std::string method = H.method;
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
if (myMeta.live){
|
if (myMeta.live){
|
||||||
updateMeta();
|
updateMeta();
|
||||||
}
|
}
|
||||||
std::string url = H.url;
|
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){
|
if (url.find(".mpd") != std::string::npos){
|
||||||
H.Clean();
|
H.Clean();
|
||||||
H.SetHeader("Content-Type", "application/xml");
|
H.SetHeader("Content-Type", "application/xml");
|
||||||
H.SetHeader("Cache-Control", "no-cache");
|
H.SetHeader("Cache-Control", "no-cache");
|
||||||
H.setCORSHeaders();
|
H.setCORSHeaders();
|
||||||
|
if(method == "OPTIONS" || method == "HEAD"){
|
||||||
|
H.SendResponse("200", "OK", myConn);
|
||||||
|
H.Clean();
|
||||||
|
return;
|
||||||
|
}
|
||||||
H.SetBody(buildManifest());
|
H.SetBody(buildManifest());
|
||||||
H.SendResponse("200", "OK", myConn);
|
H.SendResponse("200", "OK", myConn);
|
||||||
DEVEL_MSG("Manifest sent");
|
DEVEL_MSG("Manifest sent");
|
||||||
|
@ -569,6 +566,11 @@ namespace Mist {
|
||||||
H.SetHeader("Content-Type", "video/mp4");
|
H.SetHeader("Content-Type", "video/mp4");
|
||||||
H.SetHeader("Cache-Control", "no-cache");
|
H.SetHeader("Cache-Control", "no-cache");
|
||||||
H.setCORSHeaders();
|
H.setCORSHeaders();
|
||||||
|
if(method == "OPTIONS" || method == "HEAD"){
|
||||||
|
H.SendResponse("200", "OK", myConn);
|
||||||
|
H.Clean();
|
||||||
|
return;
|
||||||
|
}
|
||||||
H.StartResponse(H, myConn);
|
H.StartResponse(H, myConn);
|
||||||
|
|
||||||
if (url.find("init.m4s") != std::string::npos){
|
if (url.find("init.m4s") != std::string::npos){
|
||||||
|
|
|
@ -217,8 +217,15 @@ namespace Mist {
|
||||||
if (H.GetVar("s").size() && H.GetVar("s") == SUPER_SECRET){
|
if (H.GetVar("s").size() && H.GetVar("s") == SUPER_SECRET){
|
||||||
H.Clean();
|
H.Clean();
|
||||||
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
|
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.SetBody("Yup");
|
||||||
H.SendResponse("200", "OK", myConn);
|
H.SendResponse("200", "OK", myConn);
|
||||||
|
H.Clean();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*LTS-END*/
|
/*LTS-END*/
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutHTTPMinimalServer::onHTTP(){
|
void OutHTTPMinimalServer::onHTTP(){
|
||||||
|
std::string method = H.method;
|
||||||
//determine actual file path for the request
|
//determine actual file path for the request
|
||||||
std::string path = resolved_path + H.url.substr(8);
|
std::string path = resolved_path + H.url.substr(8);
|
||||||
|
|
||||||
|
@ -45,6 +46,11 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
H.Clean();
|
H.Clean();
|
||||||
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
|
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.SetBody("File not found");
|
||||||
H.SendResponse("404", "OK", myConn);
|
H.SendResponse("404", "OK", myConn);
|
||||||
return;
|
return;
|
||||||
|
@ -59,6 +65,12 @@ namespace Mist {
|
||||||
H.Clean();
|
H.Clean();
|
||||||
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
|
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
|
||||||
H.SetHeader("Content-Length", filesize);
|
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);
|
H.SendResponse("200", "OK", myConn);
|
||||||
while (inFile.good()){
|
while (inFile.good()){
|
||||||
inFile.read(buffer, 4096);
|
inFile.read(buffer, 4096);
|
||||||
|
|
|
@ -27,9 +27,17 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutHTTPTS::onHTTP(){
|
void OutHTTPTS::onHTTP(){
|
||||||
|
std::string method = H.method;
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
H.Clean();
|
H.Clean();
|
||||||
H.SetHeader("Content-Type", "video/mp2t");
|
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);
|
H.StartResponse(H, myConn);
|
||||||
parseData = true;
|
parseData = true;
|
||||||
wantRequest = false;
|
wantRequest = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue