diff --git a/lib/remote/actionshandler.cpp b/lib/remote/actionshandler.cpp index abe926e42..f0610236e 100644 --- a/lib/remote/actionshandler.cpp +++ b/lib/remote/actionshandler.cpp @@ -17,11 +17,9 @@ REGISTER_URLHANDLER("/v1/actions", ActionsHandler); bool ActionsHandler::HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/actionshandler.hpp b/lib/remote/actionshandler.hpp index fe249fa1d..99f36d83c 100644 --- a/lib/remote/actionshandler.hpp +++ b/lib/remote/actionshandler.hpp @@ -17,11 +17,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/configfileshandler.cpp b/lib/remote/configfileshandler.cpp index e159539eb..46b631b33 100644 --- a/lib/remote/configfileshandler.cpp +++ b/lib/remote/configfileshandler.cpp @@ -15,11 +15,9 @@ REGISTER_URLHANDLER("/v1/config/files", ConfigFilesHandler); bool ConfigFilesHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/configfileshandler.hpp b/lib/remote/configfileshandler.hpp index a9d836a99..e59abf399 100644 --- a/lib/remote/configfileshandler.hpp +++ b/lib/remote/configfileshandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/configpackageshandler.cpp b/lib/remote/configpackageshandler.cpp index eff0eae17..ec38be97a 100644 --- a/lib/remote/configpackageshandler.cpp +++ b/lib/remote/configpackageshandler.cpp @@ -12,11 +12,9 @@ REGISTER_URLHANDLER("/v1/config/packages", ConfigPackagesHandler); bool ConfigPackagesHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/configpackageshandler.hpp b/lib/remote/configpackageshandler.hpp index 04905fcc0..1c7c6b6a2 100644 --- a/lib/remote/configpackageshandler.hpp +++ b/lib/remote/configpackageshandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; private: diff --git a/lib/remote/configstageshandler.cpp b/lib/remote/configstageshandler.cpp index b52bc3d07..52a6c0c1a 100644 --- a/lib/remote/configstageshandler.cpp +++ b/lib/remote/configstageshandler.cpp @@ -16,11 +16,9 @@ std::atomic ConfigStagesHandler::m_RunningPackageUpdates (false); bool ConfigStagesHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/configstageshandler.hpp b/lib/remote/configstageshandler.hpp index 9f9047581..12b89d92a 100644 --- a/lib/remote/configstageshandler.hpp +++ b/lib/remote/configstageshandler.hpp @@ -16,11 +16,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; private: diff --git a/lib/remote/consolehandler.cpp b/lib/remote/consolehandler.cpp index 59a57b843..88e78c2b7 100644 --- a/lib/remote/consolehandler.cpp +++ b/lib/remote/consolehandler.cpp @@ -55,11 +55,9 @@ static void EnsureFrameCleanupTimer() bool ConsoleHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/consolehandler.hpp b/lib/remote/consolehandler.hpp index 616376527..10783364f 100644 --- a/lib/remote/consolehandler.hpp +++ b/lib/remote/consolehandler.hpp @@ -24,11 +24,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; static std::vector GetAutocompletionSuggestions(const String& word, ScriptFrame& frame); diff --git a/lib/remote/createobjecthandler.cpp b/lib/remote/createobjecthandler.cpp index 0e2795df0..dafd9d6e7 100644 --- a/lib/remote/createobjecthandler.cpp +++ b/lib/remote/createobjecthandler.cpp @@ -17,11 +17,9 @@ REGISTER_URLHANDLER("/v1/objects", CreateObjectHandler); bool CreateObjectHandler::HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/createobjecthandler.hpp b/lib/remote/createobjecthandler.hpp index 526f4b0c2..44da88a06 100644 --- a/lib/remote/createobjecthandler.hpp +++ b/lib/remote/createobjecthandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/deleteobjecthandler.cpp b/lib/remote/deleteobjecthandler.cpp index 49f6d890e..5eb5d3cd7 100644 --- a/lib/remote/deleteobjecthandler.cpp +++ b/lib/remote/deleteobjecthandler.cpp @@ -17,11 +17,9 @@ REGISTER_URLHANDLER("/v1/objects", DeleteObjectHandler); bool DeleteObjectHandler::HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/deleteobjecthandler.hpp b/lib/remote/deleteobjecthandler.hpp index d212b7750..27185cac3 100644 --- a/lib/remote/deleteobjecthandler.hpp +++ b/lib/remote/deleteobjecthandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/eventshandler.cpp b/lib/remote/eventshandler.cpp index d8160d9fe..30a2f888d 100644 --- a/lib/remote/eventshandler.cpp +++ b/lib/remote/eventshandler.cpp @@ -41,11 +41,9 @@ const String l_ApiQuery (""); bool EventsHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace asio = boost::asio; diff --git a/lib/remote/eventshandler.hpp b/lib/remote/eventshandler.hpp index 13e64400c..999337a7d 100644 --- a/lib/remote/eventshandler.hpp +++ b/lib/remote/eventshandler.hpp @@ -16,11 +16,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/httphandler.cpp b/lib/remote/httphandler.cpp index 0d7a3ad97..6079109d0 100644 --- a/lib/remote/httphandler.cpp +++ b/lib/remote/httphandler.cpp @@ -48,11 +48,9 @@ void HttpHandler::Register(const Url::Ptr& url, const HttpHandler::Ptr& handler) void HttpHandler::ProcessRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { Dictionary::Ptr node = m_UrlTree; @@ -105,7 +103,7 @@ void HttpHandler::ProcessRequest( */ try { for (const HttpHandler::Ptr& handler : handlers) { - if (handler->HandleRequest(waitGroup, stream, request, response, yc, server)) { + if (handler->HandleRequest(waitGroup, request, response, yc)) { processed = true; break; } diff --git a/lib/remote/httphandler.hpp b/lib/remote/httphandler.hpp index 461495935..878787121 100644 --- a/lib/remote/httphandler.hpp +++ b/lib/remote/httphandler.hpp @@ -30,21 +30,17 @@ public: virtual bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) = 0; static void Register(const Url::Ptr& url, const HttpHandler::Ptr& handler); static void ProcessRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ); private: diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index bca378aa7..8ec0b9253 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -41,8 +41,7 @@ HttpServerConnection::HttpServerConnection(const WaitGroup::Ptr& waitGroup, cons } HttpServerConnection::HttpServerConnection(const WaitGroup::Ptr& waitGroup, const String& identity, bool authenticated, const Shared::Ptr& stream, boost::asio::io_context& io) - : m_WaitGroup(waitGroup), m_Stream(stream), m_Seen(Utility::GetTime()), m_IoStrand(io), m_ShuttingDown(false), m_HasStartedStreaming(false), - m_CheckLivenessTimer(io) + : m_WaitGroup(waitGroup), m_Stream(stream), m_Seen(Utility::GetTime()), m_IoStrand(io), m_ShuttingDown(false), m_CheckLivenessTimer(io) { if (authenticated) { m_ApiUser = ApiUser::GetByClientCN(identity); @@ -100,29 +99,6 @@ void HttpServerConnection::Disconnect(boost::asio::yield_context yc) } } -void HttpServerConnection::StartStreaming() -{ - namespace asio = boost::asio; - - m_HasStartedStreaming = true; - - HttpServerConnection::Ptr keepAlive (this); - - IoEngine::SpawnCoroutine(m_IoStrand, [this, keepAlive](asio::yield_context yc) { - if (!m_ShuttingDown) { - char buf[128]; - asio::mutable_buffer readBuf (buf, 128); - boost::system::error_code ec; - - do { - m_Stream->async_read_some(readBuf, yc[ec]); - } while (!ec); - - Disconnect(yc); - } - }); -} - bool HttpServerConnection::Disconnected() { return m_ShuttingDown; @@ -388,11 +364,8 @@ bool EnsureValidBody( static inline bool ProcessRequest( - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - HttpServerConnection& server, - bool& hasStartedStreaming, const WaitGroup::Ptr& waitGroup, std::chrono::steady_clock::duration& cpuBoundWorkTime, boost::asio::yield_context& yc @@ -404,7 +377,7 @@ bool ProcessRequest( CpuBoundWork handlingRequest (yc); cpuBoundWorkTime = std::chrono::steady_clock::now() - start; - HttpHandler::ProcessRequest(waitGroup, stream, request, response, yc, server); + HttpHandler::ProcessRequest(waitGroup, request, response, yc); } catch (const std::exception& ex) { response.SendJsonError(request.Params(), 500, "Unhandled exception", DiagnosticInformation(ex)); response.Write(yc); @@ -501,7 +474,7 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc) m_Seen = std::numeric_limits::max(); - if (!ProcessRequest(*m_Stream, request, response, *this, m_HasStartedStreaming, m_WaitGroup, cpuBoundWorkTime, yc)) { + if (!ProcessRequest(request, response, m_WaitGroup, cpuBoundWorkTime, yc)) { break; } diff --git a/lib/remote/httpserverconnection.hpp b/lib/remote/httpserverconnection.hpp index 7bbae1d35..79ab1ae07 100644 --- a/lib/remote/httpserverconnection.hpp +++ b/lib/remote/httpserverconnection.hpp @@ -30,7 +30,6 @@ public: const Shared::Ptr& stream); void Start(); - void StartStreaming(); bool Disconnected(); private: @@ -41,7 +40,6 @@ private: String m_PeerAddress; boost::asio::io_context::strand m_IoStrand; bool m_ShuttingDown; - bool m_HasStartedStreaming; boost::asio::deadline_timer m_CheckLivenessTimer; HttpServerConnection(const WaitGroup::Ptr& waitGroup, const String& identity, bool authenticated, diff --git a/lib/remote/infohandler.cpp b/lib/remote/infohandler.cpp index f44be8148..635c9f7e0 100644 --- a/lib/remote/infohandler.cpp +++ b/lib/remote/infohandler.cpp @@ -10,11 +10,9 @@ REGISTER_URLHANDLER("/", InfoHandler); bool InfoHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/infohandler.hpp b/lib/remote/infohandler.hpp index f6316b140..214ed574a 100644 --- a/lib/remote/infohandler.hpp +++ b/lib/remote/infohandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/mallocinfohandler.cpp b/lib/remote/mallocinfohandler.cpp index 0239a0217..c348279b4 100644 --- a/lib/remote/mallocinfohandler.cpp +++ b/lib/remote/mallocinfohandler.cpp @@ -19,11 +19,9 @@ REGISTER_URLHANDLER("/v1/debug/malloc_info", MallocInfoHandler); bool MallocInfoHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream&, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context&, - HttpServerConnection& + boost::asio::yield_context& ) { namespace http = boost::beast::http; diff --git a/lib/remote/mallocinfohandler.hpp b/lib/remote/mallocinfohandler.hpp index f0afae960..48ab699dc 100644 --- a/lib/remote/mallocinfohandler.hpp +++ b/lib/remote/mallocinfohandler.hpp @@ -14,11 +14,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/modifyobjecthandler.cpp b/lib/remote/modifyobjecthandler.cpp index 3e78f1bd7..80c922d36 100644 --- a/lib/remote/modifyobjecthandler.cpp +++ b/lib/remote/modifyobjecthandler.cpp @@ -15,11 +15,9 @@ REGISTER_URLHANDLER("/v1/objects", ModifyObjectHandler); bool ModifyObjectHandler::HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/modifyobjecthandler.hpp b/lib/remote/modifyobjecthandler.hpp index 7052ecfce..897db1769 100644 --- a/lib/remote/modifyobjecthandler.hpp +++ b/lib/remote/modifyobjecthandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/objectqueryhandler.cpp b/lib/remote/objectqueryhandler.cpp index e11c8a080..d14182af5 100644 --- a/lib/remote/objectqueryhandler.cpp +++ b/lib/remote/objectqueryhandler.cpp @@ -90,11 +90,9 @@ Dictionary::Ptr ObjectQueryHandler::SerializeObjectAttrs(const Object::Ptr& obje bool ObjectQueryHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/objectqueryhandler.hpp b/lib/remote/objectqueryhandler.hpp index 874f70a70..f95ffe940 100644 --- a/lib/remote/objectqueryhandler.hpp +++ b/lib/remote/objectqueryhandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; private: diff --git a/lib/remote/statushandler.cpp b/lib/remote/statushandler.cpp index 62eac432b..6a7acc5c4 100644 --- a/lib/remote/statushandler.cpp +++ b/lib/remote/statushandler.cpp @@ -70,11 +70,9 @@ public: bool StatusHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/statushandler.hpp b/lib/remote/statushandler.hpp index c41136986..65c409a80 100644 --- a/lib/remote/statushandler.hpp +++ b/lib/remote/statushandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/templatequeryhandler.cpp b/lib/remote/templatequeryhandler.cpp index 0b5a46556..5a0ea091a 100644 --- a/lib/remote/templatequeryhandler.cpp +++ b/lib/remote/templatequeryhandler.cpp @@ -77,11 +77,9 @@ public: bool TemplateQueryHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/templatequeryhandler.hpp b/lib/remote/templatequeryhandler.hpp index 0dfbc458c..d02a72456 100644 --- a/lib/remote/templatequeryhandler.hpp +++ b/lib/remote/templatequeryhandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/typequeryhandler.cpp b/lib/remote/typequeryhandler.cpp index 1aab413e8..fdf02eafe 100644 --- a/lib/remote/typequeryhandler.cpp +++ b/lib/remote/typequeryhandler.cpp @@ -48,11 +48,9 @@ public: bool TypeQueryHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/typequeryhandler.hpp b/lib/remote/typequeryhandler.hpp index c94bd2511..9cbd76e60 100644 --- a/lib/remote/typequeryhandler.hpp +++ b/lib/remote/typequeryhandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; }; diff --git a/lib/remote/variablequeryhandler.cpp b/lib/remote/variablequeryhandler.cpp index d31477433..75ea969df 100644 --- a/lib/remote/variablequeryhandler.cpp +++ b/lib/remote/variablequeryhandler.cpp @@ -58,11 +58,9 @@ public: bool VariableQueryHandler::HandleRequest( const WaitGroup::Ptr&, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) { namespace http = boost::beast::http; diff --git a/lib/remote/variablequeryhandler.hpp b/lib/remote/variablequeryhandler.hpp index af312e23e..ec1ffba5e 100644 --- a/lib/remote/variablequeryhandler.hpp +++ b/lib/remote/variablequeryhandler.hpp @@ -15,11 +15,9 @@ public: bool HandleRequest( const WaitGroup::Ptr& waitGroup, - AsioTlsStream& stream, HttpRequest& request, HttpResponse& response, - boost::asio::yield_context& yc, - HttpServerConnection& server + boost::asio::yield_context& yc ) override; };