Streaming
When responses are too large to buffer in memory — or when data arrives over time — chunked transfer encoding lets you send data in pieces. Prism provides both a writer-based API and anAsyncStream-based API.
AsyncStream Responses
The simplest way to stream: pass anAsyncStream<Data> and Prism handles the chunked encoding.
Stream from AsyncStream
Transfer-Encoding: chunked automatically — no Content-Length needed.
Stream Writer
For more control over when chunks are written, usePrismStreamWriter:
Using Stream Writer
Large File Download
Streaming a Large File
Reading Request Bodies in Chunks
For large uploads, split the incoming body into fixed-size chunks:Chunked Request Reading
Newline-Delimited JSON Stream
Combine streaming with structured data for progress reporting:NDJSON Stream
Chunked Response Helper
Create a response pre-configured for chunked transfer:Pre-configured Chunked Response