Skip to main content

read_bounded

Function read_bounded 

Source
pub async fn read_bounded(
    response: Response,
    max_bytes: usize,
) -> Result<Vec<u8>, ReadBoundedError>
Expand description

Reads at most max_bytes of response’s body.

Neither path this can take ever holds more than one chunk past max_bytes in memory: a declared Content-Length over the bound is refused before reading anything, and a body that lies about its length, or declines to declare one at all, is refused the instant it crosses the bound rather than once it finishes.