mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-14 10:29:35 +00:00
Ignore a leading UTF-8 BOM in an SSE stream
The SSE spec strips one BOM at the start of the stream, but SSEClient kept it as part of the first field name, so the first event was silently dropped.
This commit is contained in:
1 parent
885ed54b10
commit
fee592c2c2
2 files changed
+17
No files matched your search
@@ -22793,6 +22793,16 @@ TEST_F(SSEParsingTest, FieldNameOnlyWithCarriageReturn) {
|
||||
EXPECT_EQ(msgs[0].data, "");
|
||||
}
|
||||
|
||||
TEST_F(SSEParsingTest, LeadingByteOrderMarkIgnored) {
|
||||
// Only a BOM at the start of the stream is ignored
|
||||
auto msgs = parse("\xEF\xBB\xBF"
|
||||
"data: first\n\n"
|
||||
"\xEF\xBB\xBF"
|
||||
"data: second\n\n");
|
||||
ASSERT_EQ(msgs.size(), 1u);
|
||||
EXPECT_EQ(msgs[0].data, "first");
|
||||
}
|
||||
|
||||
TEST_F(SSEParsingTest, UnknownFieldsIgnored) {
|
||||
auto msgs = parse("unknown: value\ndata: hello\n\n");
|
||||
ASSERT_EQ(msgs.size(), 1u);
|
||||
|
||||
Reference in new issue
Block a user