From d944d4600e5d1f5d986aeb8cee15f7bd059d5970 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 22 Jun 2018 15:54:35 +0200 Subject: [PATCH] Added CORS headers and OPTIONS/HEAD support for HTTP internal's onFail responses. --- src/output/output_http_internal.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/output/output_http_internal.cpp b/src/output/output_http_internal.cpp index e16ed1b2..93debc70 100644 --- a/src/output/output_http_internal.cpp +++ b/src/output/output_http_internal.cpp @@ -61,6 +61,7 @@ namespace Mist { } void OutHTTP::onFail(){ + std::string method = H.method; // send logo icon if (H.url.length() > 4 && H.url.substr(H.url.length() - 4, 4) == ".ico"){ sendIcon(); @@ -81,7 +82,14 @@ namespace Mist { H.Clean(); H.SetBody("if (!mistvideo){var mistvideo = {};}\nmistvideo['" + streamName + "'] = "+json_resp.toString()+";\n"); } + H.setCORSHeaders(); + if(method == "OPTIONS" || method == "HEAD"){ + H.SendResponse("200", "OK", myConn); + H.Clean(); + return; + } H.SendResponse("200", "Stream not found", myConn); + H.Clean(); return; } INFO_MSG("Failing: %s", H.url.c_str());