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:
yhirose committed 2026-10-18 12:41:23 -04:00
1 parent 2e3cb0f985
commit cc9d67404e
2 files changed
+10 -1

No files matched your search

+8
View File
@@ -25263,6 +25263,14 @@ TEST_F(SSEParsingTest, EventWithoutDataResetsEventType) {
EXPECT_EQ(msgs[0].data, "hello");
}
TEST_F(SSEParsingTest, EmptyEventTypeIsMessage) {
// Also when the empty field replaces an earlier type
auto msgs = parse("event:\ndata: a\n\nevent: update\nevent:\ndata: b\n\n");
ASSERT_EQ(msgs.size(), 2u);
EXPECT_EQ(msgs[0].event, "message");
EXPECT_EQ(msgs[1].event, "message");
}
TEST_F(SSEParsingTest, EventWithoutDataUpdatesLastEventId) {
// The first connection sends only an id; the second echoes back the
// Last-Event-ID it was reconnected with