create_body_reader
create_body_reader(body: async_io.Pollable, chunk_size: int = 4096) -> BufferedReaderCreate a file-like reader for streaming a Fastly HTTP body.
This function returns a BufferedReader that streams the body on-demand, avoiding the need to buffer the entire body in memory. The returned reader is compatible with the WSGI InputStream Protocol (PEP 3333).
The returned reader supports all standard file operations: read(), readline(), readlines(), and iteration. Note that seeking is not supported as the body is a forward-only stream.
Parameters
- body: async_io.Pollable
Fastly HTTP body handle to read from
- chunk_size: intoptional =
4096 Size of chunks to read at a time (default: 4096)
Returns
BufferedReader
A BufferedReader that streams the body content (WSGI compatible)
def handle(request, body): reader = create_body_reader(body) # Read entire body full_body = reader.read() # Or read line by line for line in reader: process(line)