An incremental Transfer-Encoding: chunked request-body decoder.
Line endings are strict CRLF, as in the book's chunkScan: a bare LF
in a size line, after chunk data, or in a trailer is :bad_chunk
(step.muro's chunk-trailer-bare and chunk-ext-lf owe 400).
The book validates chunk framing for a body it buffers (chunkScan) and owes 400 or 413 itself. A body the book hands to the host to stream (a chunk tail past 16384 bytes) is decoded here as it is read from the socket. Everything is a binary; decoded data is iodata of binaries, never a list of octets.
Summary
Functions
Decode a whole chunked body the book has already framed.
Feed bytes. Returns {:more, data, dec} when the body is not
finished, {:done, data, rest} once the last chunk and trailers are
read (rest is bytes past the message), or {:error, reason}.
Types
Functions
Decode a whole chunked body the book has already framed.
@spec feed(t(), binary()) :: {:more, iodata(), t()} | {:done, iodata(), binary()} | {:error, atom()}
Feed bytes. Returns {:more, data, dec} when the body is not
finished, {:done, data, rest} once the last chunk and trailers are
read (rest is bytes past the message), or {:error, reason}.
@spec new(non_neg_integer() | :infinity) :: t()