mochiweb_headers
Case preserving (but case insensitive) HTTP Header dictionary.
Case preserving (but case insensitive) HTTP Header dictionary.
DATA TYPES
headers()
key() = atom() | binary() | string()
value() = atom() | binary() | string() | integer()
Functions
default(K::key(), V::value(), T::headers()) -> headers()
Insert the pair into the headers if it does not already exist.
default_from_list(List::[{key(), value()}], T::headers()) -> headers()
Insert pairs into the headers for keys that do not already exist.
delete_any(K::key(), T::headers()) -> headers()
Delete the header corresponding to key if it is present.
empty() -> headers()
Create an empty headers structure.
enter(K::key(), V::value(), T::headers()) -> headers()
Insert the pair into the headers, replacing any pre-existing key.
enter_from_list(List::[{key(), value()}], T::headers()) -> headers()
Insert pairs into the headers, replace any values for existing keys.
from_binary(RawHttpHeader::iolist()) -> headers()
Transforms a raw HTTP header into a mochiweb headers structure.
The given raw HTTP header can be one of the following:
1) A string or a binary representing a full HTTP header ending with double CRLF. Examples:
"Content-Length: 47\r\nContent-Type: text/plain\r\n\r\n" <<"Content-Length: 47\r\nContent-Type: text/plain\r\n\r\n">>
2) A list of binaries or strings where each element represents a raw HTTP header line ending with a single CRLF. Examples:
[<<"Content-Length: 47\r\n">>, <<"Content-Type: text/plain\r\n">>] ["Content-Length: 47\r\n", "Content-Type: text/plain\r\n"] ["Content-Length: 47\r\n", <<"Content-Type: text/plain\r\n">>]
from_list(List::[{key(), value()}]) -> headers()
Construct a headers() from the given list.
get_primary_value(K::key(), T::headers()) -> string() | undefined
Return the value of the given header up to the first semicolon using a case insensitive search. undefined will be returned for keys that are not present.
get_value(K::key(), T::headers()) -> string() | undefined
Return the value of the given header using a case insensitive search. undefined will be returned for keys that are not present.
insert(K::key(), V::value(), T::headers()) -> headers()
Insert the pair into the headers, merging with any pre-existing key. A merge is done with Value = V0 ++ ", " ++ V1.
lookup(K::key(), T::headers()) -> {value, {key(), string()}} | none
Return the case preserved key and value for the given header using a case insensitive search. none will be returned for keys that are not present.
make(L::headers() | [{key(), value()}]) -> headers()
Construct a headers() from the given list.
to_list(T::headers()) -> [{key(), string()}]
Return the contents of the headers. The keys will be the exact key that was first inserted (e.g. may be an atom or binary, case is preserved).