docs / http/headers

http/headers

Functions

append

fn(headers: List<(Str, Str)>, name: Str, value: Str) -> List<(Str, Str)>

Append a header, preserving any existing headers with the same name.

from_pairs

fn(arr: Array<Array<Str>>) -> List<(Str, Str)>

Convert Array<Array<Str>> [[k, v], ...] back to List<(Str, Str)>.

get

fn(headers: List<(Str, Str)>, name: Str) -> Option<Str>

Get the first value for a header name.

get_all

fn(headers: List<(Str, Str)>, name: Str) -> List<Str>

Get all values for a header name, in insertion order.

has

fn(headers: List<(Str, Str)>, name: Str) -> Bool

Check if a header with the given name exists.

new

fn () -> List<(Str, Str)>

Create an empty headers collection. Headers are a List<(Str, Str)>, preserving insertion order and duplicate keys (required by HTTP spec for Set-Cookie, etc.).

remove

fn(headers: List<(Str, Str)>, name: Str) -> List<(Str, Str)>

Remove all headers with the given name.

set

fn(headers: List<(Str, Str)>, name: Str, value: Str) -> List<(Str, Str)>

Set a header, replacing all existing headers with the same name.

to_pairs

fn(hdrs: List<(Str, Str)>) -> Array<Array<Str>>

Convert List<(Str, Str)> headers to Array<Array<Str>> [[k, v], ...] for passing across the EXTERN boundary.