Copyright © 2007, 2008 Scott Parish <srp@srparish.net>
Authors: Scott Parish (srp@srparish.net).
This module acts an an associative data-structure to hold headers. This can be used for both request as well as response headers.
This module is fairly flexible with inputs. Stringish inputs can always be given in the form of iolists() or atoms(). Headerish inputs can always be given as headers(), tuple_list(), dict(), gb_trees(), or as a socket to read/parse them from. However, outputs will always be header() or string(). In the case of names, since HTTP header names are case insensitive they will always be returned lower cased.headerish() = headers() | tuple_list() | dict() | gb_trees() | crary:crary_req()
headers() = term()
Currently headers are backed by gb_trees, but please don't depend on this as it may change in the future.
stringish() = iolist() | atom()
| add/2 | Return headers() extended with the specified header/headers. |
| add/3 | Return headers() extended with the specified header. |
| extend/2 | Return headers() extended with the specified headers. |
| foreach/2 | Call F({K, V}) for each header in Headers. |
| from_sock/1 | Create a header() structure from the socket. |
| from_sock/2 | Create a header() structure from the socket. |
| get/2 | Return the value of the header given by the Name. |
| get/3 | Return the value of the header given by the Name. |
| has/2 | Does Headers include Name?. |
| lookup/2 | Does Headers include Name?. |
| new/0 | Create an empty headers() structure. |
| new/1 | Create a header() structure from data. |
| to_list/1 | Convert Headers to a tuple_list(). |
| write/2 | Write Headers to socket, including terminating blank line. |
add(KVList::NameValue | [NameValue], Headers::headerish()) -> headers()
Return headers() extended with the specified header/headers.
add(Name::stringish(), Value::stringish(), Headers::headerish()) -> headers()
Return headers() extended with the specified header.
extend(KVList::[{Name::stringish(), Value::stringish()}], Headers::headerish()) -> headers()
Return headers() extended with the specified headers.
foreach(F::function(), Headers::headerish()) -> ok
Call F({K, V}) for each header in Headers.
from_sock(Crary_req::Sock) -> headers()
Create a header() structure from the socket. Opts is
used to set the timeout.
from_sock(S::Sock, Opts::crary:proplist()) -> headers()
Create a header() structure from the socket. Opts is
used to set the timeout.
get(Name::stringish(), Headers::headerish()) -> string()
throws {crary_headers_error, {name_not_found, Name}}
Return the value of the header given by the Name.
get(Name::stringish(), Headers::headerish(), Default::term()) -> string() | Default
Return the value of the header given by the Name.
has(Name::stringish(), Headers::headerish()) -> bool()
Does Headers include Name?
lookup(Name::stringish(), Headers::headerish()) -> bool()
Does Headers include Name?
new() -> crary_headers()
Create an empty headers() structure.
new(List::headerish()) -> headers()
Create a header() structure from data. The data can
either be a socket or an existing datastructure including gb_trees,
tuplelists, dicts. If a socket was given the headers are read/2 off the socket, parsed, and returned in
the header()
to_list(Headers::headerish()) -> tuple_list()
Convert Headers to a tuple_list(). Perfect for
printing or looping over.
See also: foreach/2.
write(S::crary_sock:sock() | crary:crary_req(), Headers::headerish()) -> ok
Write Headers to socket, including terminating blank line.
Generated by EDoc, Mar 14 2008, 22:35:53.