View Source hackney_headers (hackney v1.23.0)

module to manipulate HTTP headers

Summary

Functions

Parse a content disposition.

Parse a content type.

Delete the header corresponding to key if it is present.
fold the list of headers
get the value of the header
join value and params in a binary
Insert the pair into the headers, merging with any pre-existing key. A merge is done with Value = V0 ++ ", " ++ V1.
same as insert/3 but allows to add params to the header value.
Create a binary header
initialise an header dict

Semantically parse headers.

store the pair into the headers, replacing any pre-existing key.
return all the headers as a binary that can be sent over the wire.
extend the headers with a new list of {Key, Value} pair.

Types

disposition/0

-type disposition() :: {binary(), [{binary(), binary()}]}.

headers/0

-type headers() :: any().

Functions

content_disposition(Data)

-spec content_disposition(binary()) -> disposition().
Parse a content disposition.

content_type(Data)

-spec content_type(binary()) -> any().

Parse a content type.

We lowercase the charset header as we know it's case insensitive.

delete(Key, Headers)

Delete the header corresponding to key if it is present.

fold(Fun, Acc0, Headers)

fold the list of headers

get_value(Key, Headers)

get the value of the header

get_value(Key, Headers, Default)

header_value(Value, Params)

join value and params in a binary

insert(Key, Value, Headers)

Insert the pair into the headers, merging with any pre-existing key. A merge is done with Value = V0 ++ ", " ++ V1.

insert(Key, Value, Params, Headers)

same as insert/3 but allows to add params to the header value.

make_header(Name, Value)

Create a binary header

make_header(Name, Value, Params)

new()

-spec new() -> headers().
initialise an header dict

new(D)

-spec new(list()) -> headers().

parse(Name, Headers)

-spec parse(binary(), list() | headers()) -> any() | undefined | {error, badarg}.

Semantically parse headers.

When the value isn't found, a proper default value for the type returned is used as a return value.

See also: parse/3.

store(Key, Value, Headers)

store the pair into the headers, replacing any pre-existing key.

to_binary(Headers)

return all the headers as a binary that can be sent over the wire.

to_list(Headers)

update(Headers, KVs)

extend the headers with a new list of {Key, Value} pair.