From 6fde95fad082fa7d6fc54f2ef8584e06fb116d42 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Thu, 1 Jun 2023 07:33:34 -0700 Subject: Server-sent-event fixes This makes several changes to server-sent events to allow it to merge to master. The routing system has been removed in leiu of using content-type eventstream detection. Timers have been added to the sse connections, and sse connections now rely on async_wait, rather than a full read. Tested: WIP Signed-off-by: Ed Tanous Change-Id: Id0ff0ebc2b3a795b3dba008e440556a9fdd882c2 --- http/routing.hpp | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'http/routing.hpp') diff --git a/http/routing.hpp b/http/routing.hpp index ead3af9eca..ac1c310ae2 100644 --- a/http/routing.hpp +++ b/http/routing.hpp @@ -391,7 +391,7 @@ class SseSocketRule : public BaseRule } #ifndef BMCWEB_ENABLE_SSL - void handleUpgrade(const Request& req, + void handleUpgrade(const Request& /*req*/, const std::shared_ptr& /*asyncResp*/, boost::asio::ip::tcp::socket&& adaptor) override { @@ -399,11 +399,11 @@ class SseSocketRule : public BaseRule crow::sse_socket::ConnectionImpl> myConnection = std::make_shared< crow::sse_socket::ConnectionImpl>( - req, std::move(adaptor), openHandler, closeHandler); + std::move(adaptor), openHandler, closeHandler); myConnection->start(); } #else - void handleUpgrade(const Request& req, + void handleUpgrade(const Request& /*req*/, const std::shared_ptr& /*asyncResp*/, boost::beast::ssl_stream&& adaptor) override @@ -412,7 +412,7 @@ class SseSocketRule : public BaseRule boost::beast::ssl_stream>> myConnection = std::make_shared>>( - req, std::move(adaptor), openHandler, closeHandler); + std::move(adaptor), openHandler, closeHandler); myConnection->start(); } #endif @@ -432,12 +432,8 @@ class SseSocketRule : public BaseRule } private: - std::function&, - const crow::Request&, - const std::shared_ptr&)> - openHandler; - std::function&)> - closeHandler; + std::function openHandler; + std::function closeHandler; }; template @@ -461,13 +457,6 @@ struct RuleParameterTraits return *p; } - self_t& name(std::string_view name) noexcept - { - self_t* self = static_cast(this); - self->nameStr = name; - return *self; - } - self_t& methods(boost::beast::http::verb method) { self_t* self = static_cast(this); @@ -1184,15 +1173,6 @@ class Router return true; } - static bool isSseRoute(Request& req) - { - return std::any_of(sse_socket::sseRoutes.begin(), - sse_socket::sseRoutes.end(), - [&req](const char* sseRoute) { - return (req.url().encoded_path() == sseRoute); - }); - } - static bool isUserPrivileged(Request& req, const std::shared_ptr& asyncResp, -- cgit v1.2.3