Skip to main content

parse_body

Function parse_body 

Source
pub fn parse_body(
    buffer: &[u8],
    body_length: BodyLength,
    config: &BodyConfig,
) -> Result<Option<Vec<u8>>, BodyError>
Expand description

Parse a request body from a buffer given the body length indicator.

This is the main entry point for body parsing. It dispatches to the appropriate reader based on Content-Length or Transfer-Encoding.

§Arguments

  • buffer - The buffer containing the body (after headers)
  • body_length - The body length indicator from header parsing
  • config - Body reading configuration

§Returns

Returns the parsed body bytes, or None if no body is expected.

§Errors

Returns an error if:

  • The body exceeds the configured size limit
  • The chunked encoding is malformed
  • The buffer is incomplete