Fixed JSON error responses to internal HTTP output.
This commit is contained in:
parent
5e4a56222e
commit
8fa8a5d736
3 changed files with 19 additions and 1 deletions
|
@ -10,7 +10,7 @@ namespace Mist {
|
|||
virtual ~HTTPOutput(){};
|
||||
static void init(Util::Config * cfg);
|
||||
void onRequest();
|
||||
void onFail();
|
||||
virtual void onFail();
|
||||
virtual void onHTTP(){};
|
||||
virtual void requestHandler();
|
||||
static bool listenMode(){return false;}
|
||||
|
|
|
@ -19,6 +19,23 @@ namespace Mist {
|
|||
return !(config->getString("ip").size());
|
||||
}
|
||||
|
||||
void OutHTTP::onFail(){
|
||||
INFO_MSG("Failing: %s", H.url.c_str());
|
||||
if (H.url.size() >= 3 && H.url.substr(H.url.size() - 3) == ".js"){
|
||||
if (H.url.size() >= 5 && H.url.substr(0, 5) == "/json"){
|
||||
H.Clean();
|
||||
H.SetBody("{\"error\":\"Could not retrieve stream. Sorry.\"}\n");
|
||||
}else{
|
||||
H.Clean();
|
||||
H.SetBody("mistvideo['" + streamName + "'] = {\"error\":\"Could not retrieve stream. Sorry.\"};\n");
|
||||
}
|
||||
H.SendResponse("200", "Stream not found", myConn);
|
||||
}else{
|
||||
HTTPOutput::onFail();
|
||||
}
|
||||
Output::onFail();
|
||||
}
|
||||
|
||||
void OutHTTP::init(Util::Config * cfg){
|
||||
HTTPOutput::init(cfg);
|
||||
capa.removeMember("deps");
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Mist {
|
|||
~OutHTTP();
|
||||
static void init(Util::Config * cfg);
|
||||
static bool listenMode();
|
||||
virtual void onFail();
|
||||
void onHTTP();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue