accept both addresses ending with rpc or rpc/. Accept all content type starting with application/json

This commit is contained in:
orignal
2026-08-31 21:51:30 -04:00
parent 6d7ee819eb
commit 421136b264
+6 -2
View File
@@ -539,7 +539,8 @@ namespace torrents
auto tunnel = m_Server.GetTunnel ( {path.data (), path.size ()}); // boost::beast::string_view to std::string_view
if (tunnel)
{
if (m_Request[boost::beast::http::field::content_type] == "application/json" ||
static constexpr std::string_view appjson { "application/json" };
if (m_Request[boost::beast::http::field::content_type].compare (0, appjson.size (), appjson) || // starts with
m_Request[boost::beast::http::field::content_type] == "application/x-www-form-urlencoded")
{
#ifdef JSON_SUPPORTED
@@ -616,7 +617,10 @@ namespace torrents
std::string rpcPath ("/");
if (!path.empty ())
rpcPath += std::string (path) + "/";
rpcPath += "rpc/";
// insert both pathes rpc and rpc/
rpcPath += "rpc";
m_Tunnels.emplace (rpcPath, tunnel);
rpcPath += "/";
m_Tunnels.emplace (rpcPath, tunnel);
}