Streaming basics
TheResponse object supports streaming via the standard body property, which returns a ReadableStream<Uint8Array>. This allows you to process large responses incrementally.
Key behaviors
Lazy initialization
Lazy initialization
The
body property is lazily initialized. It returns null for empty responses or a ReadableStream for non-empty responses.Consumption tracking
Consumption tracking
Accessing
response.body does not mark it as consumed. Only reading from the stream sets bodyUsed to true.Clone before consuming
Clone before consuming
You can call
response.clone() to create a duplicate response before the body is consumed.Single read
Single read
Once consumed via
json(), text(), arrayBuffer(), or stream reading, the body cannot be read again.