Skip to main content

bytes_with_limit

Function bytes_with_limit 

Source
pub async fn bytes_with_limit(
    resp: Response,
    limit: usize,
) -> Result<Vec<u8>, HttpClientError>
Expand description

Read a response body into a Vec<u8>, aborting as soon as the byte count exceeds limit. Prevents a hostile or buggy upstream from OOM-killing the process by streaming an unbounded body.

The caller is responsible for JSON/UTF-8 interpretation. Use together with MAX_RESPONSE_BYTES for the default cap.