From 693f2d018a20668161b161c21b8506abceb6a76f Mon Sep 17 00:00:00 2001 From: CastagnaIT Date: Wed, 21 Aug 2024 16:50:09 +0200 Subject: [PATCH] [StreamUtils] Set headers also on inputstream.adaptive.stream_headers Usually if a service require user-agent header must be set on both manifests and streams --- src/iptvsimple/utilities/StreamUtils.cpp | 33 ++++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/iptvsimple/utilities/StreamUtils.cpp b/src/iptvsimple/utilities/StreamUtils.cpp index ca49cca0..7df000a1 100644 --- a/src/iptvsimple/utilities/StreamUtils.cpp +++ b/src/iptvsimple/utilities/StreamUtils.cpp @@ -20,6 +20,25 @@ using namespace iptvsimple; using namespace iptvsimple::data; using namespace iptvsimple::utilities; +namespace +{ +bool SplitUrlProtocolOpts(const std::string& streamURL, + std::string& url, + std::string& encodedProtocolOptions) +{ + size_t found = streamURL.find_first_of('|'); + if (found != std::string::npos) + { + // Headers found, split and url-encode them + url = streamURL.substr(0, found); + const std::string& protocolOptions = streamURL.substr(found + 1, streamURL.length()); + encodedProtocolOptions = StreamUtils::GetUrlEncodedProtocolOptions(protocolOptions); + return true; + } + return false; +} +} // unnamed namespace + void StreamUtils::SetAllStreamProperties(std::vector& properties, const iptvsimple::data::Channel& channel, const std::string& streamURL, bool isChannelURL, std::map& catchupProperties, std::shared_ptr& settings) { if (ChannelSpecifiesInputstream(channel)) @@ -83,19 +102,17 @@ void StreamUtils::SetAllStreamProperties(std::vector