Skip to content
English

传输与流 ​

Core · 接口与运行保证 · 返回本层目录

符号类别用途
abortableStreamfunctionRe-yield an async iterable, but reject as soon as signal aborts. The abort reason is propagated unchanged, so callers can tell user cancellation from a provider failure without inspecting messages.
readSsefunctionDecode an SSE response body into events. Framing contract: - A network chunk is not an event. Bytes are buffered until a blank line, because UTF-8 sequences, CRLF pairs and data: lines may all straddle chunk boundaries. - \r\n, \r and \n all terminate a line; a trailing \r at the end of a chunk is held back until the next chunk shows whether an \n follows. - Comment lines (leading :) are discarded; they are used as heartbeats. - The size limit applies per line and per event (1 MiB), not per network read, so many complete events coalesced into one chunk after backpressure remain valid. - Cancellation is checked between lines, so aborting while the consumer is paused stops emitting the remaining buffered events of the same chunk.
SseEventinterfaceOne dispatched SSE event, assembled from all lines up to a blank line.
SseIdleTimeoutErrorclassRaised when no bytes arrive within the configured idle window. A distinct type lets callers treat a silent connection as retryable instead of mixing it with transport or decoding failures.
SseReadOptionstypePer-read configuration; snapshotted when readSse starts.

接口参考、使用示例与开发指南。