Files
llm-wiki/raw/official-docs/whatwg-html-server-sent-events.md

8.7 KiB

title, source_type, url, archive_url, related_branches, related_projects, tags, created, last_reviewed
title source_type url archive_url related_branches related_projects tags created last_reviewed
official-doc / WHATWG HTML Living Standard — Server-Sent Events (§9.2) official-doc https://html.spec.whatwg.org/multipage/server-sent-events.html
feature-streaming-response-contract
ca-skeleton
sse
server-sent-events
whatwg
html-living-standard
streaming
eventsource
http
protocol
2026-06-02 2026-06-02

WHATWG HTML Living Standard — Server-Sent Events (§9.2)

Layer: raw/official-docs/ — WHATWG HTML Living Standard §9.2 "Server-sent events" 발췌. Strength 분류: official-standard — WHATWG HTML Living Standard 는 HTML 및 관련 Web API 의 공식 사양 기관 (WHATWG, Apple / Mozilla / Google / Microsoft 공동 관리). 검증된 요약은 /ingestwiki/concepts/ 에 별도 작성.

Parent / 활용 branch (필수)

Branch 이 자료가 정당화하는 결정
raw/branch-notes/feature-streaming-response-contract SSE (Server-Sent Events) alternative 의 프로토콜 명세 근거 — EventSource API, text/event-stream wire format, Last-Event-ID 재연결 메커니즘, retry 정책

출처 / Source

  • 원본 URL: https://html.spec.whatwg.org/multipage/server-sent-events.html
  • 아카이브 URL: (미수집)
  • 저자 / 조직: WHATWG (Web Hypertext Application Technology Working Group) — Apple, Mozilla, Google, Microsoft 참여
  • 발행일: Living Standard (지속 갱신) — 2026-06-02 기준 확인
  • 마지막 확인일: 2026-06-02

왜 저장했는지 / Why archived

feature-streaming-response-contract 의 streaming mechanism 결정에서 SSE (Server-Sent Events) alternative 의 프로토콜 수준 명세가 필요. WHATWG HTML Living Standard §9.2 는 EventSource interface, text/event-stream MIME type + wire format, Last-Event-ID 헤더 동작, 재연결 알고리즘을 normative 하게 정의하는 1차 표준 문서. SSE 의 프로토콜 제약(단방향, UTF-8 only, HTTP 위에서 작동)을 claim 수준으로 명시하기 위해 보관.

핵심 인용 / Key quotes (verbatim)

[§9.2.2 The EventSource interface] "Exposed=(Window,Worker)] interface EventSource : EventTarget { constructor(USVString url, optional EventSourceInitDict eventSourceInitDict = {}); ... };"

[§9.2.5 Interpreting an event stream] "This event stream format's MIME type is text/event-stream."

[§9.2.5 Interpreting an event stream] "Event streams in this format must always be encoded as UTF-8."

[§9.2.5 Interpreting an event stream, data field] "Append the field value to the data buffer, then append a single U+000A LINE FEED (LF) character."

[§9.2.5 Interpreting an event stream, id field] "set the last event ID buffer to the field value"

[§9.2.5 Interpreting an event stream, retry field] "interpret the field value as an integer in base ten, and set the event stream's reconnection time"

[§9.2.4 The Last-Event-ID header] "If the EventSource object's last event ID string is not the empty string... Set (Last-Event-ID, lastEventIDValue) in request's header list."

[§9.2.3 Processing model, reconnection] "Wait a delay equal to the reconnection time of the event source"

[§9.2.3 Processing model, reconnection] "if the previous attempt failed, then user agents might introduce an exponential backoff delay."

[§9.2.3 Processing model, failure] "Once the user agent has failed the connection, it does not attempt to reconnect."

Claims Extracted / 추출된 주장

Claim ID Claim (이 자료가 직접 말하는 것) Evidence quote Strength Applies to Does not prove
WHATWG-SSE-C1 SSE 의 공식 MIME type 은 text/event-stream 이며, event stream 은 반드시 UTF-8 로 인코딩되어야 한다 [§9.2.5] "This event stream format's MIME type is text/event-stream." + "Event streams in this format must always be encoded as UTF-8." official-standard SSE 를 지원하는 모든 HTTP 서버 및 브라우저 Binary data 전송이 불가하다는 뜻 (UTF-8 only). binary 데이터는 base64 인코딩 필요
WHATWG-SSE-C2 SSE wire format 은 data:, event:, id:, retry: 필드를 가진 line-based text protocol 이다 [§9.2.5] "Append the field value to the data buffer..." (data), "set the last event ID buffer to the field value" (id), "set the event stream's reconnection time" (retry) official-standard text/event-stream 응답을 파싱하는 모든 구현 커스텀 필드를 정의할 수 없다는 의미 — 사양 외 필드는 무시됨
WHATWG-SSE-C3 Last-Event-ID 헤더는 재연결 시 클라이언트가 마지막으로 받은 event ID 를 서버에 전달한다 [§9.2.4] "If the EventSource object's last event ID string is not the empty string... Set (Last-Event-ID, lastEventIDValue) in request's header list." official-standard 재연결 흐름에서 이벤트 replay 를 지원하려는 서버 구현 서버가 반드시 Last-Event-ID 를 활용해야 한다는 뜻은 아님 — 활용 여부는 서버 구현 책임
WHATWG-SSE-C4 재연결 대기 시간은 retry: 필드로 서버가 설정 가능하며, 이전 연결 실패 시 user agent 는 지수 백오프를 도입할 수 있다 [§9.2.3] "Wait a delay equal to the reconnection time of the event source" + "if the previous attempt failed, then user agents might introduce an exponential backoff delay." official-standard SSE 재연결 정책을 구현하는 서버 및 클라이언트 지수 백오프가 표준 의무 사항이라는 뜻은 아님 — "might" (MAY 수준 권고)
WHATWG-SSE-C5 EventSource interface 는 WindowWorker context 에서만 사용 가능 (서버 측 사용 불가 — 클라이언트 API) [§9.2.2] "[Exposed=(Window,Worker)] interface EventSource : EventTarget" official-standard EventSource API 를 사용하는 브라우저 + Web Worker 환경 Node.js 나 Spring 서버 측 구현에 직접 적용되지 않음 — 서버 측은 직접 text/event-stream 응답을 구현해야 함
WHATWG-SSE-C6 연결이 "failed" 처리되면 user agent 는 재연결을 시도하지 않는다 [§9.2.3] "Once the user agent has failed the connection, it does not attempt to reconnect." official-standard EventSource 연결 상태 관리 어떤 조건에서 "failed" 처리되는지는 본 인용의 문맥 이전 단계에서 정의됨 — 상세 조건은 사양 §9.2.3 전체 정독 필요

Usage Boundaries / 적용 경계

  • 이 자료가 직접 증명하는 것:
    • C1: SSE 는 text/event-stream + UTF-8 전용 프로토콜 — binary 전송은 base64 변환 필요
    • C2: SSE wire format 은 4개 필드 (data/event/id/retry) 만 정의됨 — JSON envelope 을 data: 필드 값으로 wrap 하는 방식
    • C3: Last-Event-ID 는 재연결 시 이벤트 재전송(replay) 의 공식 메커니즘
    • C4: 재연결 정책은 서버(retry:)와 클라이언트(exponential backoff) 모두 관여
    • C5: EventSource 는 브라우저/Worker 클라이언트 API — Spring 서버는 SseEmitter 로 별도 구현
  • 이 자료가 증명하지 않는 것:
    • SSE 가 WebSocket 대비 성능적으로 우위라는 주장 — 본 사양은 SSE 자체 명세만 정의
    • HTTP/2 multiplexing 환경에서 SSE connection limit 이 해소된다는 주장 — HTTP/2 spec 은 별도 문서
    • Spring SseEmitter 가 이 사양을 완전히 준수한다는 주장 — Spring vendor doc 으로 별도 검증 필요
  • 내 프로젝트에 적용하려면 추가 확인이 필요한 것:
    • ca-skeleton 의 SseEmitter 구현이 Last-Event-ID replay 를 지원할 것인지 — 서버 측 event store / replay 구현 필요
    • reverse proxy (Nginx) 의 proxy_buffering off 가 SSE 의 incremental delivery 에 미치는 영향 — RFC/Nginx 문서 별도 확인
    • HTTP/1.1 vs HTTP/2 환경에서 SSE connection 수 제한 차이 — HTTP/1.1: 도메인 당 6개 browser 제한

메모 / Notes

  • SSE 의 단방향 특성 (server → client only) 은 C5 에서 간접적으로 확인 — 표준이 "server sends events" 모델만 정의
  • retry: 필드 (C4) 는 ca-skeleton 의 heartbeat + reconnect 정책 결정에 직접 연결됨
  • Last-Event-ID (C3) 는 ca-skeleton 에서 이벤트 재전송 지원 여부를 결정할 때 핵심 claim