{
"schema": "sse-conformance-vectors/1",
"reference": "WHATWG HTML Living Standard, Server-sent events",
"encoding": {
"chunks": "each chunk is {\"text\": s} (UTF-8 bytes of the JSON string) or {\"hex\": h} (raw bytes); the input stream is the concatenation, delivered one chunk per stream item in order",
"generator.repeat_stream": "unit_text UTF-8-encoded, repeated count times, then delivered in chunk_bytes-sized chunks",
"generator.long_line": "prefix + fill_char*fill_count + suffix, UTF-8-encoded, delivered in chunk_bytes-sized chunks",
"expected.events": "ordered dispatched events; event defaults applied ('message' type); id is the last event ID string at dispatch; retry is the reconnection-time attachment (most recent retry value processed since the previous dispatched event, else null)",
"expected.events.kind=repeat": "the given event repeated count times",
"expected.events.kind=single_fill_event": "one event whose data is fill_char repeated fill_count times",
"expected.retry_updates": "ordered reconnection-time updates at field-processing time (WHATWG semantics, independent of dispatch)",
"expected.final_last_event_id": "last event ID string after EOF (commits happen at every blank line, including non-dispatched blocks)"
},
"vectors": [
{
"id": "v01-whatwg-stock-ticker",
"purpose": "spec example: multi-line data joined with LF",
"chunks": [
{
"text": "data: YHOO\ndata: +2\ndata: 10\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "YHOO\n+2\n10",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v02-whatwg-test-stream",
"purpose": "spec example: comment block, id set to 1, id reset to empty, single leading space stripped",
"chunks": [
{
"text": ": test stream\n\ndata: first event\nid: 1\n\ndata:second event\nid\n\ndata: third event\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "first event",
"id": "1",
"retry": null
},
{
"event": "message",
"data": "second event",
"id": "",
"retry": null
},
{
"event": "message",
"data": " third event",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v03-whatwg-two-events",
"purpose": "spec example: bare 'data' lines; empty-string data IS dispatched when buffer held a newline; unterminated last block discarded",
"chunks": [
{
"text": "data\n\ndata\ndata\n\ndata:\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "",
"id": "",
"retry": null
},
{
"event": "message",
"data": "\n",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v04-whatwg-space-strip",
"purpose": "spec example: 'data:test' and 'data: test' are identical",
"chunks": [
{
"text": "data:test\n\ndata: test\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "test",
"id": "",
"retry": null
},
{
"event": "message",
"data": "test",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v05-event-type-and-empty-value",
"purpose": "event field sets type; 'event:' with empty value falls back to message",
"chunks": [
{
"text": "event: add\ndata: x\n\nevent:\ndata: y\n\n"
}
],
"expected": {
"events": [
{
"event": "add",
"data": "x",
"id": "",
"retry": null
},
{
"event": "message",
"data": "y",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v06-event-type-resets-after-dispatch",
"purpose": "type buffer cleared at dispatch; next block defaults to message",
"chunks": [
{
"text": "event: add\ndata: x\n\ndata: y\n\n"
}
],
"expected": {
"events": [
{
"event": "add",
"data": "x",
"id": "",
"retry": null
},
{
"event": "message",
"data": "y",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v07-comments-ignored",
"purpose": "comment-only blocks dispatch nothing; ':' and ': text' both comments",
"chunks": [
{
"text": ": ping\n\n:\n: another\n\n"
}
],
"expected": {
"events": [],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v08-unknown-fields-ignored",
"purpose": "unknown field names ignored; comparison is literal and case-sensitive",
"chunks": [
{
"text": "foo: bar\ndata: keep\nData: nope\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "keep",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v09-colon-in-value",
"purpose": "field/value split at FIRST colon only",
"chunks": [
{
"text": "data: a:b: c\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a:b: c",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v10-one-space-only-no-tab",
"purpose": "exactly one leading space stripped; tab is not stripped",
"chunks": [
{
"text": "data: two\n\ndata:\tx\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": " two",
"id": "",
"retry": null
},
{
"event": "message",
"data": "\tx",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v11-data-nul-allowed",
"purpose": "NUL is legal in data (only id rejects it)",
"chunks": [
{
"text": "data: a\u0000b\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a\u0000b",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v12-crlf-terminators",
"purpose": "CRLF pairs are single terminators",
"chunks": [
{
"text": "data: a\r\ndata: b\r\n\r\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a\nb",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v13-cr-terminators-and-eof-cr-flush",
"purpose": "lone CR terminates a line; a lone CR at EOF is a terminator (empty line -> dispatch), not pending data",
"chunks": [
{
"text": "data: a\rdata: b\r\r"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a\nb",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v14-mixed-terminators",
"purpose": "CR, CRLF, LF mixed in one stream",
"chunks": [
{
"text": "data: a\rdata: b\r\ndata: c\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a\nb\nc",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v15-crlf-split-across-chunks",
"purpose": "CR at end of one chunk + LF at start of next is ONE terminator (must not synthesize a blank line and dispatch early)",
"chunks": [
{
"text": "data: a\r"
},
{
"text": "\ndata: b\r"
},
{
"text": "\n\r\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a\nb",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v16-cr-then-non-lf-across-chunks",
"purpose": "chunk-final CR followed by a non-LF chunk is a lone-CR terminator",
"chunks": [
{
"text": "data: a\r"
},
{
"text": "data: b\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a\nb",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v17-field-split-across-chunks",
"purpose": "field name and value arrive in pieces; the incremental parser must not reparse or corrupt",
"chunks": [
{
"text": "da"
},
{
"text": "ta: hel"
},
{
"text": "lo\n"
},
{
"text": "\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "hello",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v18-multibyte-char-split-across-chunks",
"purpose": "UTF-8 sequence (C3 A9, e-acute) split across chunks decodes intact, no replacement char",
"chunks": [
{
"hex": "646174613a20c3"
},
{
"hex": "a90a0a"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "\u00e9",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v19-bom-stripped-at-start",
"purpose": "EF BB BF at stream offset 0 stripped exactly once (incumbent 0.2.3 panics here: 1-byte slice into a 3-byte char)",
"chunks": [
{
"hex": "efbbbf"
},
{
"text": "data: hi\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "hi",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v20-bom-split-across-chunks",
"purpose": "BOM delivered one byte per chunk is still the leading BOM",
"chunks": [
{
"hex": "ef"
},
{
"hex": "bb"
},
{
"hex": "bf"
},
{
"text": "data: hi\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "hi",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v21-double-bom-only-first-stripped",
"purpose": "only ONE leading BOM stripped; second U+FEFF makes the field name '\\uFEFFdata' (unknown, ignored) so nothing dispatches",
"chunks": [
{
"hex": "efbbbfefbbbf"
},
{
"text": "data: hi\n\n"
}
],
"expected": {
"events": [],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v22-bom-mid-stream-not-stripped",
"purpose": "BOM bytes after stream start are content: '\\uFEFFdata' is an unknown field, second block dispatches nothing",
"chunks": [
{
"text": "data: a\n\n"
},
{
"hex": "efbbbf"
},
{
"text": "data: b\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v23-bom-inside-value-preserved",
"purpose": "U+FEFF inside a data value is content",
"chunks": [
{
"text": "data: a\ufeffb\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a\ufeffb",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v24-empty-data-no-dispatch",
"purpose": "block with only an event field dispatches nothing; type buffer still resets",
"chunks": [
{
"text": "event: ping\n\ndata: x\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "x",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v25-id-committed-without-dispatch",
"purpose": "dispatch step 1 commits the id buffer BEFORE the empty-data early return; id buffer is never reset",
"chunks": [
{
"text": "id: 42\n\ndata: hi\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "hi",
"id": "42",
"retry": null
}
],
"final_last_event_id": "42",
"retry_updates": []
}
},
{
"id": "v26-id-only-stream",
"purpose": "a stream of just 'id: 9' + blank line yields no events but the last event ID string is 9 (reconnection state)",
"chunks": [
{
"text": "id: 9\n\n"
}
],
"expected": {
"events": [],
"final_last_event_id": "9",
"retry_updates": []
}
},
{
"id": "v27-id-persists-across-events",
"purpose": "events without an id field inherit the last seen id",
"chunks": [
{
"text": "id: 7\ndata: a\n\ndata: b\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a",
"id": "7",
"retry": null
},
{
"event": "message",
"data": "b",
"id": "7",
"retry": null
}
],
"final_last_event_id": "7",
"retry_updates": []
}
},
{
"id": "v28-id-nul-rejected",
"purpose": "an id value containing NUL is ignored wholesale; buffer keeps its prior value",
"chunks": [
{
"text": "id: 1\ndata: a\n\nid: x\u0000y\ndata: b\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a",
"id": "1",
"retry": null
},
{
"event": "message",
"data": "b",
"id": "1",
"retry": null
}
],
"final_last_event_id": "1",
"retry_updates": []
}
},
{
"id": "v29-retry-valid-and-invalid",
"purpose": "all-digits retry accepted; non-digit and trailing-space values ignored",
"chunks": [
{
"text": "retry: 3000\ndata: a\n\nretry: 30x0\ndata: b\n\nretry: 12 \ndata: c\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a",
"id": "",
"retry": 3000
},
{
"event": "message",
"data": "b",
"id": "",
"retry": null
},
{
"event": "message",
"data": "c",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": [
3000
]
}
},
{
"id": "v30-retry-in-non-dispatched-block",
"purpose": "reconnection time is set when the field is PROCESSED, not at dispatch; a retry-only block must not lose the value",
"chunks": [
{
"text": "retry: 5000\n\ndata: x\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "x",
"id": "",
"retry": 5000
}
],
"final_last_event_id": "",
"retry_updates": [
5000
]
}
},
{
"id": "v31-retry-empty-value-ignored",
"purpose": "pinned P2: empty retry value is ignored (no digits)",
"chunks": [
{
"text": "retry\ndata: a\n\nretry: \ndata: b\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a",
"id": "",
"retry": null
},
{
"event": "message",
"data": "b",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v32-eof-discards-unterminated-block",
"purpose": "terminated lines but no final blank line: block discarded at EOF",
"chunks": [
{
"text": "data: kept\n\ndata: lost\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "kept",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v33-eof-discards-partial-line",
"purpose": "stream ends mid-line: partial line and its block discarded",
"chunks": [
{
"text": "data: kept\n\ndata: hal"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "kept",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "v34-invalid-utf8-replacement",
"purpose": "pinned P1: invalid byte 0xFF becomes U+FFFD, stream keeps parsing, no error and no panic",
"chunks": [
{
"text": "data: a"
},
{
"hex": "ff"
},
{
"text": "b\n\n"
}
],
"expected": {
"events": [
{
"event": "message",
"data": "a\ufffdb",
"id": "",
"retry": null
}
],
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "g01-many-events-one-byte-chunks",
"purpose": "throughput shape: 2000 small events delivered a byte at a time; perf gate input (linear time required)",
"generator": {
"kind": "repeat_stream",
"unit_text": "data: 0123456789ab\n\n",
"count": 2000,
"chunk_bytes": 1
},
"expected": {
"events": {
"kind": "repeat",
"event": {
"event": "message",
"data": "0123456789ab",
"id": "",
"retry": null
},
"count": 2000
},
"final_last_event_id": "",
"retry_updates": []
}
},
{
"id": "g02-single-huge-line-one-byte-chunks",
"purpose": "the quadratic killer: one 64 KiB data line delivered a byte at a time; incumbent rescans the whole partial line per chunk",
"generator": {
"kind": "long_line",
"prefix": "data: ",
"fill_char": "a",
"fill_count": 65536,
"suffix": "\n\n",
"chunk_bytes": 1
},
"expected": {
"events": {
"kind": "single_fill_event",
"event": "message",
"fill_char": "a",
"fill_count": 65536,
"id": "",
"retry": null
},
"final_last_event_id": "",
"retry_updates": []
}
}
]
}