# `MuroPlug.Chunked`
[🔗](https://github.com/murolang/muro_plug/blob/main/lib/muro_plug/chunked.ex#L1)

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.

# `t`

```elixir
@type t() :: %MuroPlug.Chunked{
  max: term(),
  pending: term(),
  state: term(),
  total: term()
}
```

# `decode_all`

```elixir
@spec decode_all(binary()) :: {:ok, binary(), binary()} | {:error, atom()}
```

Decode a whole chunked body the book has already framed.

# `feed`

```elixir
@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}`.

# `new`

```elixir
@spec new(non_neg_integer() | :infinity) :: t()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
