pub enum BodyLength {
Empty,
Known(u64),
Chunked,
CloseDelimited,
Omitted,
}Expand description
How the body after an encoded head is framed.
Variants§
Empty
No body. A Content-Length in the head, if any, must be 0.
Known(u64)
Exactly this many bytes, framed by Content-Length.
Chunked
Transfer-Encoding: chunked; the only framing that carries trailers.
CloseDelimited
Responses only: no framing, the body ends when the connection closes
(RFC 9112 section 6.3, rule 8). The head must carry neither
Content-Length nor Transfer-Encoding, and after
finish the host closes the connection - that close
is the end of the body. Adding connection: close is the host’s
choice; the peer reads to EOF either way.
Omitted
Responses only: the head’s framing headers are sent exactly as given,
and no body follows them. This is a response to HEAD, which advertises
the Content-Length (or chunked coding) it would have sent, and a
304, which may do the same. A 204 or 1xx may not advertise a length
at all (RFC 9110 sections 8.6 and 15.2), so either header is refused
there. The encoder cannot see the request method, so a HEAD response is
the host’s word. No framing header is added, and body
accepts only empty slices.