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 <edtanous@google.com>
Change-Id: Id0ff0ebc2b3a795b3dba008e440556a9fdd882c2
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 1b85c6b..7ae22e9 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -243,12 +243,14 @@
[self(shared_from_this())](crow::Response& thisRes) {
self->completeRequest(thisRes);
});
-
+ bool isSse =
+ isContentTypeAllowed(req->getHeaderValue("Accept"),
+ http_helpers::ContentType::EventStream, false);
if ((thisReq.isUpgrade() &&
boost::iequals(
thisReq.getHeaderValue(boost::beast::http::field::upgrade),
"websocket")) ||
- (Handler::isSseRoute(*req)))
+ isSse)
{
asyncResp->res.setCompleteRequestHandler(
[self(shared_from_this())](crow::Response& thisRes) {