# `Letterbox.MIME.Header`
[🔗](https://github.com/hattoriai/letterbox/blob/v0.1.0-rc.0/lib/letterbox/mime/header.ex#L1)

The headers of an email or of one of its parts (RFC 5322 and MIME), read
as mail clients write them, not only as the RFCs say they should.

  * `parse/1` - a block of headers as `{name, value}` pairs, in their
    order: names in lowercase, values unfolded and not yet decoded.
  * `decode/1` - a value's encoded words (RFC 2047,
    `=?utf-8?Q?Jos=C3=A9?=`) in UTF-8, adjacent ones of one charset
    joined before they are read, so a character split across two words
    survives; raw 8-bit text (RFC 6532) as UTF-8, else as Windows-1252.
  * `params/1` - a structured value (`Content-Type`,
    `Content-Disposition`): its value and its parameters, with RFC 2231's
    (`filename*=utf-8''praia%20%C3%A0%20tarde.jpg`, and the parts of a
    long one, `filename*0*`, `filename*1*`) and the encoded words that
    Outlook and Gmail put in quoted ones.

# `t`

```elixir
@type t() :: {String.t(), String.t()}
```

A header: its name in lowercase, and its value as it came, unfolded.

# `decode`

```elixir
@spec decode(String.t() | nil) :: String.t() | nil
```

A header's value in UTF-8: its encoded words decoded, and the spaces
between two of them taken out, as RFC 2047 says.

# `get`

```elixir
@spec get([t()], String.t()) :: String.t() | nil
```

The first value of `name` (lowercase) in `headers`, or nil.

# `get_all`

```elixir
@spec get_all([t()], String.t()) :: [String.t()]
```

Every value of `name` (lowercase) in `headers`, in their order.

# `params`

```elixir
@spec params(String.t() | nil) ::
  {String.t() | nil, %{required(String.t()) =&gt; String.t()}}
```

A structured value and its parameters: `{"multipart/mixed",
%{"boundary" => "…"}}`. The value is in lowercase and so are the
parameters' names; their values are decoded (RFC 2231, RFC 2047, quoted
strings) to UTF-8.

# `parse`

```elixir
@spec parse(binary()) :: [t()]
```

The headers of a block of header lines (`CRLF` or `LF`), unfolded. A
line that is not a header and does not continue one is left out.

---

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