传输与流
Core · 接口与运行保证 · 返回本层目录
| 符号 | 类别 | 用途 |
|---|---|---|
abortableStream | function | Re-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. |
readSse | function | Decode 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. |
SseEvent | interface | One dispatched SSE event, assembled from all lines up to a blank line. |
SseIdleTimeoutError | class | Raised 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. |
SseReadOptions | type | Per-read configuration; snapshotted when readSse starts. |