Skip to main content

validate_content_length

Function validate_content_length 

Source
pub fn validate_content_length(
    content_length: usize,
    config: &BodyConfig,
) -> Result<(), BodyError>
Expand description

Validates body size against Content-Length header before reading.

Call this early (before buffering) to reject oversized requests.

§Arguments

  • content_length - The Content-Length header value
  • config - Body reading configuration

§Errors

Returns BodyError::TooLarge if the content length exceeds the limit.