diff -U2 -r /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsRPC.cpp /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsRPC.cpp --- /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsRPC.cpp 2026-08-24 19:38:13.000000000 +0000 +++ /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsRPC.cpp 2026-08-24 19:23:47.000000000 +0000 @@ -432,6 +432,29 @@ if (!ecode) { - if (m_Request.method() == boost::beast::http::verb::post) + if (m_Request.method() == boost::beast::http::verb::options) { + m_Response.version (11); // HTTP/1.1 + m_Response.result (204); + m_Response.set (boost::beast::http::field::access_control_allow_origin, "*"); + m_Response.set (boost::beast::http::field::access_control_allow_methods, "GET, POST, OPTIONS"); + m_Response.set (boost::beast::http::field::access_control_allow_headers, "Content-Type, Authorization"); + + m_Response.keep_alive(m_Request.keep_alive()); + m_Response.prepare_payload (); + boost::beast::http::async_write (m_Socket, m_Response, + [s = shared_from_this ()](const boost::system::error_code& ecode, size_t bytes_transferred) + { + if (ecode) + LogPrint (eLogWarning, "TorrentsRPC: Failed to send response: ", ecode.message ()); + }); + } + else if (m_Request.method() == boost::beast::http::verb::post) + { + m_Response.set( + boost::beast::http::field::access_control_allow_origin, + "*"); + m_Response.set( + boost::beast::http::field::access_control_allow_headers, + "Content-Type, Authorization"); auto path = m_Request.target (); auto tunnel = m_Server.GetTunnel ( {path.data (), path.size ()}); // boost::beast::string_view to std::string_view @@ -458,6 +481,4 @@ } } - else if (m_Request.method() == boost::beast::http::verb::options) - SendResponse (boost::beast::http::status::no_content, "", true); else SendResponse (boost::beast::http::status::method_not_allowed); @@ -465,15 +486,10 @@ } - void TorrentsRPCSession::SendResponse (boost::beast::http::status result, std::string_view data, bool isOptions) + void TorrentsRPCSession::SendResponse (boost::beast::http::status result, std::string_view data) { m_Response.version (11); // HTTP/1.1 m_Response.result (result); m_Response.set (boost::beast::http::field::server, "i2pd torents RPC"); - m_Response.set (boost::beast::http::field::access_control_allow_origin, "*"); - m_Response.set (boost::beast::http::field::access_control_allow_headers, "Content-Type, Authorization"); - if (isOptions) - m_Response.set (boost::beast::http::field::access_control_allow_methods, "GET, POST, OPTIONS"); - else - m_Response.set(boost::beast::http::field::content_type, (result == boost::beast::http::status::ok) ? "application/json; charset=UTF-8" : "text/plain"); + m_Response.set(boost::beast::http::field::content_type, (result == boost::beast::http::status::ok) ? "application/json; charset=UTF-8" : "text/plain"); m_Response.body () = data; m_Response.prepare_payload (); diff -U2 -r /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsRPC.h /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsRPC.h --- /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsRPC.h 2026-08-24 19:38:13.000000000 +0000 +++ /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsRPC.h 2026-08-24 19:23:47.000000000 +0000 @@ -36,5 +36,5 @@ void HandleRequest (const boost::system::error_code& ecode, size_t bytes_transferred); - void SendResponse (boost::beast::http::status result, std::string_view data = "", bool isOptions = false); + void SendResponse (boost::beast::http::status result, std::string_view data = ""); private: