Headers

AA-like structure for storing headers, allowing for case insensitivity and multiple values per key.

Constructors

this
this(string[string] aa)
this(string[][string] aa)

Initialize from a D associative array.

Members

Functions

add
void add(string name, string value)

Add a value for the given header. Adds a new instance of the header if one already existed.

get
string get(string key, string def)

Retrieve the value of the given header if it is present, otherwise return def.

getAll
inout(string)[] getAll(string key)

Retrieve all values of the given header.

getLazy
string getLazy(string key, string def)

Lazy version of get.

opApply
int opApply(int delegate(ref string name, ref string value) dg)
int opApply(int delegate(ref const(string) name, ref const(string) value) dg)

Iterate over all headers, including multiple instances of the seame header.

opBinaryRight
inout(string)* opBinaryRight(string name)

If the given header exists, return a pointer to the first value. Otherwise, return null.

opCast
bool opCast()

True-ish if any headers have been set.

opCast
string[string] opCast()

Converts to a D associative array, with at most one value per header. Warning: discards repeating headers!

opCast
string[][string] opCast()

Converts to a D associative array.

opIndex
inout(string) opIndex(string name)

If multiple headers with this name are present, only the first one is returned.

opIndexAssign
string opIndexAssign(string value, string name)

Sets the given header to the given value, overwriting any previous values.

remove
void remove(string name)

Remove the given header. Does nothing if the header was not present.

require
string require(string key, string value)

If the given header is not yet present, add it with the given value.

Properties

dup
Headers dup [@property getter]

Creates and returns a copy of this Headers instance.

length
size_t length [@property getter]

Returns the number of headers and values (including duplicate headers).

Meta