Skip to main content

Module sse

Module sse 

Source
Expand description

Server-Sent Events in tests: TestResponse::sse returns a TestSse, which reads the response’s text/event-stream body — streamed (Sse::stream, Response::stream_pipe) as it arrives, or buffered (Sse::into_response) at once — and hands out SseFrames.

SseParser is the parser underneath, usable on its own: it follows the HTML Standard’s event-stream rules (lines end in CRLF, LF or CR; : starts a comment; data lines join with \n; a block without data is not dispatched; the event type defaults to message). It loops over its input, never recursing, and refuses an event (or a line) over MAX_EVENT_BYTES instead of buffering without bound.

Structs§

SseFrame
One dispatched Server-Sent Event.
SseParser
An incremental text/event-stream parser: feed it bytes in any chunks, get back the events they completed.
TestSse
Server-Sent Events read from a test response; see the module docs.

Constants§

MAX_EVENT_BYTES
The most one event (all its lines) or one unfinished line may hold: 8 MiB. Past it SseParser::feed returns an error.