Skip to main content

MAX_BODY_BYTES

Constant MAX_BODY_BYTES 

Source
pub const MAX_BODY_BYTES: usize = _; // 5_242_880usize
Expand description

Hard cap on the response body we will read (5 MiB). The HTML extractor turns a page into a few KB of text, so a multi-megabyte body is almost never worth the bandwidth, memory, and parse time — and an unbounded read is a DoS lever. Bodies over the cap are truncated (not errored): partial content is still useful and the extractor copes with truncated HTML.

The cap counts bytes after transparent gzip/brotli decoding, so it also bounds a decompression bomb.