Skip to main content

body_mode

Function body_mode 

Source
pub fn body_mode(head: &HttpHead) -> Result<HttpBodyMode, NetError>
Expand description

Classify how the body should be read, matching the client’s precedence.

Extracted from sim-lib-agent-runner-http’s read_response:

  1. Transfer-Encoding: chunked -> HttpBodyMode::Chunked.
  2. otherwise a present, non-zero Content-Length -> HttpBodyMode::ContentLength.
  3. otherwise (no/zero length) -> HttpBodyMode::UntilEof.

The client treated a missing or 0 Content-Length identically (read to EOF), so a literal Content-Length: 0 maps to UntilEof here, not HttpBodyMode::Empty. An invalid Content-Length is rejected.