mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-19 11:19:36 +00:00
Dispatch an SSE event with an empty type as "message"
An `event:` line without a value left the type empty, so the event
never reached on_event("message"), and on_message saw an empty type.
The HTML standard dispatches an event with an empty type as
"message".
This commit is contained in:
1 parent
2e3cb0f985
commit
cc9d67404e
2 files changed
+10
-1
No files matched your search
@@ -5045,7 +5045,8 @@ inline bool SSEClient::parse_sse_line(const std::string &line, SSEMessage &msg,
|
||||
|
||||
// Handle known fields
|
||||
if (field == "event") {
|
||||
msg.event = value;
|
||||
// An empty event type is dispatched as "message" per the SSE spec
|
||||
msg.event = value.empty() ? std::string("message") : std::move(value);
|
||||
} else if (field == "data") {
|
||||
// Multiple data lines are concatenated with newlines
|
||||
if (has_data) { msg.data += "\n"; }
|
||||
|
||||
Reference in new issue
Block a user