Maintains a set of HTTP tokens. These tokens include headers, query-
parameters, and anything else vaguely related. Both input and output
are supported, though a subclass may choose to expose as read-only.
All tokens are mapped directly onto a buffer, so there is no memory
allocation or copying involved.
- this(char separator, bool inclusive = false) ¶#
-
Construct a set of tokens based upon the given delimiter,
and an indication of whether said delimiter should be
considered part of the left side (effectively the name).
The latter is useful with headers, since the seperating
':' character should really be considered part of the
name for purposes of subsequent token matching.
- this(HttpTokens source) ¶#
-
Clone a source set of HttpTokens
- void parse(InputBuffer input) [abstract] ¶#
-
Read all tokens. Everything is mapped rather than being
allocated & copied
- void parse(char[] content) ¶#
-
Parse an input string.
- HttpTokens reset() ¶#
-
Reset this set of tokens.
- bool isParsed() ¶#
-
Have tokens been parsed yet?
- void setParsed(bool parsed) ¶#
-
Indicate whether tokens have been parsed or not.
- char[] get(char[] name, char[] ret = null) ¶#
-
Return the value of the provided header, or null if the
header does not exist
- int getInt(char[] name, int ret = -1) ¶#
-
Return the integer value of the provided header, or the
provided default-vaule if the header does not exist
- Time getDate(char[] name, Time date = Time.epoch) ¶#
-
Return the date value of the provided header, or the
provided default-value if the header does not exist
- int opApply(int delegate(ref HttpToken) dg) ¶#
-
Iterate over the set of tokens
- void produce(size_t delegate(void[]) consume, char[] eol = null) ¶#
-
Output the token list to the provided consumer
- bool handleMissingSeparator(char[] s, ref HttpToken element) [protected] ¶#
-
overridable method to handle the case where a token does
not have a separator. Apparently, this can happen in HTTP
usage
- bool split(Token t, ref HttpToken element) [private, final] ¶#
-
split basic token into an HttpToken
- FilteredTokens createFilter(char[] match) ¶#
-
Create a filter for iterating over the tokens matching
a particular name.
- class FilteredTokens [private, static] ¶#
-
Implements a filter for iterating over tokens matching
a particular name. We do it like this because there's no
means of passing additional information to an opApply()
method.
- this(HttpTokens tokens, char[] match) ¶#
-
Construct this filter upon the given tokens, and
set the pattern to match against.
- int opApply(int delegate(ref HttpToken) dg) ¶#
-
Iterate over all tokens matching the given name
- bool isSpace(char c) [private] ¶#
-
Is the argument a whitespace character?
- char[] trim(char[] source) [private] ¶#
-
Trim the provided string by stripping whitespace from
both ends. Returns a slice of the original content.
- char[] formatTokens(OutputBuffer dst, char[] delim) ¶#
-
these should be exposed carefully ******************
Return a char[] representing the output. An empty array
is returned if output was not configured. This perhaps
could just return our 'output' buffer content, but that
would not reflect deletes, or seperators. Better to do
it like this instead, for a small cost.
- void add(char[] name, void delegate(OutputBuffer) value) [protected] ¶#
-
Add a token with the given name. The content is provided
via the specified delegate. We stuff this name & content
into the output buffer, and map a new Token onto the
appropriate buffer slice.
- void add(char[] name, char[] value) [protected] ¶#
-
Add a simple name/value pair to the output
- void addInt(char[] name, int value) [protected] ¶#
-
Add a name/integer pair to the output
- void addDate(char[] name, Time value) [protected] ¶#
-
Add a name/date(long) pair to the output
- bool remove(char[] name) [protected] ¶#
-
remove a token from our list. Returns false if the named
token is not found.