---
title: create_body_reader
summary: Create a file-like reader for streaming a Fastly HTTP body.
url: https://www.fastly.com/documentation/reference/compute/sdks/python/fastly_compute/utils/fn.create_body_reader/
---

**Kind:** Function  
**Module:** [utils](https://www.fastly.com/documentation/reference/compute/sdks/python/fastly_compute/utils/)  
**Package:** fastly-compute 0.1.3  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/utils.py#L55

```python
create_body_reader(body: async_io.Pollable, chunk_size: int = 4096) -> BufferedReader
```

Create 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`: `int` (optional) = `4096` — Size of chunks to read at a time (default: 4096)

**Returns**

`BufferedReader`

A BufferedReader that streams the body content (WSGI compatible)

```python
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)
```
