From 8ce3498269da78bda91c3a3984dde8c734544542 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 25 Nov 2019 11:29:16 +0100 Subject: [PATCH 1/3] Optimized HTTP parser to not attempt POST variable parsing on _all_ body payloads, but only POSTed payloads --- lib/http_parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/http_parser.cpp b/lib/http_parser.cpp index 85c2fdfb..e9fe47b3 100644 --- a/lib/http_parser.cpp +++ b/lib/http_parser.cpp @@ -875,7 +875,8 @@ bool HTTP::Parser::parse(std::string &HTTPbuffer){ HTTPbuffer.erase(0, toappend); } if (length == body.length()){ - parseVars(body, vars); // parse POST variables + //parse POST variables + if (method == "POST"){parseVars(body, vars);} return true; }else{ return false; From 45b245ad4e18c6d9596373d0e881bc03bbc4d613 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 25 Nov 2019 11:29:27 +0100 Subject: [PATCH 2/3] Improved input shutdown reason detection --- src/input/input.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/input/input.cpp b/src/input/input.cpp index b78b6f83..0afbf895 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -448,9 +448,9 @@ namespace Mist { getNext(); nProxy.userClient.keepAlive(); } - if (!thisPacket){return "Invalid packet";} - if (!config->is_active){return "received deactivate signal";} if (!nProxy.userClient.isAlive()){return "buffer shutdown";} + if (!config->is_active){return "received deactivate signal";} + if (!thisPacket){return "Invalid packet";} return "Unknown"; } From 9a1b4fb8728f1da948367d9d6368b3ee387d94d9 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 12 Nov 2019 11:01:20 +0100 Subject: [PATCH 3/3] Fixed support for inputs with URL parameters --- lib/stream.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/stream.cpp b/lib/stream.cpp index 60fb711c..a9062722 100644 --- a/lib/stream.cpp +++ b/lib/stream.cpp @@ -288,6 +288,8 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir } JSON::Value Util::getInputBySource(const std::string &filename, bool isProvider){ + std::string tmpFn = filename; + if (tmpFn.find('?') != std::string::npos){tmpFn.erase(tmpFn.find('?'), std::string::npos);} JSON::Value ret; // Attempt to load up configuration and find this stream @@ -318,8 +320,8 @@ JSON::Value Util::getInputBySource(const std::string &filename, bool isProvider) MEDIUM_MSG("Checking input %s: %s (%s)", inputs.getIndiceName(i).c_str(), tmp_input.getMember("name").asString().c_str(), source.c_str()); - if (filename.substr(0, front.size()) == front && - filename.substr(filename.size() - back.size()) == back){ + if (tmpFn.substr(0, front.size()) == front && + tmpFn.substr(tmpFn.size() - back.size()) == back){ if (tmp_input.getMember("non-provider") && !isProvider){ noProviderNoPick = true; continue; @@ -336,8 +338,7 @@ JSON::Value Util::getInputBySource(const std::string &filename, bool isProvider) MEDIUM_MSG("Checking input %s: %s (%s)", inputs.getIndiceName(i).c_str(), tmp_input.getMember("name").asString().c_str(), source.c_str()); - if (filename.substr(0, front.size()) == front && - filename.substr(filename.size() - back.size()) == back){ + if (tmpFn.substr(0, front.size()) == front && tmpFn.substr(tmpFn.size() - back.size()) == back){ if (tmp_input.getMember("non-provider") && !isProvider){ noProviderNoPick = true; continue; @@ -351,9 +352,9 @@ JSON::Value Util::getInputBySource(const std::string &filename, bool isProvider) } if (!selected){ if (noProviderNoPick){ - INFO_MSG("Not a media provider for input: %s", filename.c_str()); + INFO_MSG("Not a media provider for input: %s", tmpFn.c_str()); }else{ - FAIL_MSG("No compatible input found for: %s", filename.c_str()); + FAIL_MSG("No compatible input found for: %s", tmpFn.c_str()); } }else{ ret = input.asJSON();