diff options
author | Ed Tanous <ed@tanous.net> | 2024-01-31 02:56:37 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2024-03-18 20:02:13 +0300 |
commit | 8f79c5b6a2d53d7b2ea44a2a540369cb191a3b14 (patch) | |
tree | dd5f88f75e2145fb725cacf87939f818c1bf5b5d /http/routing | |
parent | c3805d43db7b5f4e11af39582a48aa8255383716 (diff) | |
download | bmcweb-8f79c5b6a2d53d7b2ea44a2a540369cb191a3b14.tar.xz |
Add unit test for SSE
Writing this test exposed some bugs in SSE that got merged.
sendSSEHeader was never called, leading to a connection that starts
and immediately closes with no error code.
This issue has been corrected in code, such that the sockets start.
To allow for unit tests, the io_service needs to be passed into the
class, previously, the SSE connection was pulling the io_context from
the DBus connection, which is odd, given that the SSE connection has
no other dependencies on DBus.
Unit tests should help keep it working.
Tested: Unit tests pass.
Change-Id: I48080d2a94b6349989f556cd1c7b103bad498526
Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'http/routing')
-rw-r--r-- | http/routing/sserule.hpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/http/routing/sserule.hpp b/http/routing/sserule.hpp index c0a4e504b3..1a422a8268 100644 --- a/http/routing/sserule.hpp +++ b/http/routing/sserule.hpp @@ -31,7 +31,7 @@ class SseSocketRule : public BaseRule } #ifndef BMCWEB_ENABLE_SSL - void handleUpgrade(const Request& /*req*/, + void handleUpgrade(const Request& req, const std::shared_ptr<bmcweb::AsyncResp>& /*asyncResp*/, boost::asio::ip::tcp::socket&& adaptor) override { @@ -39,11 +39,11 @@ class SseSocketRule : public BaseRule crow::sse_socket::ConnectionImpl<boost::asio::ip::tcp::socket>> myConnection = std::make_shared< crow::sse_socket::ConnectionImpl<boost::asio::ip::tcp::socket>>( - std::move(adaptor), openHandler, closeHandler); + *req.ioService, std::move(adaptor), openHandler, closeHandler); myConnection->start(); } #else - void handleUpgrade(const Request& /*req*/, + void handleUpgrade(const Request& req, const std::shared_ptr<bmcweb::AsyncResp>& /*asyncResp*/, boost::beast::ssl_stream<boost::asio::ip::tcp::socket>&& adaptor) override @@ -52,7 +52,7 @@ class SseSocketRule : public BaseRule boost::beast::ssl_stream<boost::asio::ip::tcp::socket>>> myConnection = std::make_shared<crow::sse_socket::ConnectionImpl< boost::beast::ssl_stream<boost::asio::ip::tcp::socket>>>( - std::move(adaptor), openHandler, closeHandler); + *req.ioService, std::move(adaptor), openHandler, closeHandler); myConnection->start(); } #endif |