Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

HttpTokens Class Reference

Inheritance diagram for HttpTokens:

IWritable HttpHeaders HttpParams HttpMutableHeaders HttpMutableParams HttpQueryParams List of all members.

Public Member Functions

 this (char separator, bool inclusive=false)
 this (HttpTokens source)
void parse (IBuffer input)
void parse (char[] content)
void reset ()
bool isParsed ()
void setParsed (bool parsed)
char[] get (char[] name, char[] ret=null)
int getInt (char[] name, int ret=-1)
ulong getDate (char[] name, ulong date=Rfc1123.InvalidEpoch)
int opApply (int(*dg)(inout HttpToken))
void write (IWriter writer)
private bool split (Token t, inout HttpToken element)
FilteredTokens createFilter (char[] match)
char[] toOutputString ()

Static Public Member Functions

static this ()

Protected Member Functions

bool handleMissingSeparator (char[] s, inout HttpToken element)
void setOutputBuffer (IBuffer output)
IBuffer getOutputBuffer ()
void add (char[] name, void(*dg)(IBuffer))
void add (char[] name, char[] value)
void addInt (char[] name, int value)
void addDate (char[] name, ulong value)

Protected Attributes

TokenStack stack

Private Member Functions

bool isSpace (char c)
char[] trim (char[] source)

Private Attributes

IBuffer input
IBuffer output
bool parsed
bool inclusive
char separator
char[1] sepString

Static Private Attributes

char[] emptyString

Classes

class  FilteredTokens

Detailed Description

Maintains a set of HTTP tokens. These tokens include headers, query- parameters, and anything else vaguely similar. 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.

Note that this class does not support deleting tokens. Supporting such operations require a different approach, such as mapping the tokens into a temporary buffer, and then setting token content in the stack to be null when it is deleted. This could be implemented as a wrapper upon the subclasses of HttpToken.

Definition at line 84 of file HttpTokens.d.


Member Function Documentation

static this  )  [inline, static]
 

Setup an empty character array for later assignment.

Reimplemented in HttpHeaders, HttpHeaders, HttpParams, HttpParams, and HttpQueryParams.

Definition at line 102 of file HttpTokens.d.

References emptyString.

this char  separator,
bool  inclusive = false
[inline]
 

Construct a set of tokens based upon the given delimeter, and an indication of whether said delimeter 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.

Definition at line 119 of file HttpTokens.d.

References inclusive, input, separator, sepString, stack, and TokenStack.

this HttpTokens  source  )  [inline]
 

Clone a source set of HttpTokens

Definition at line 139 of file HttpTokens.d.

References TokenStack::clone(), inclusive, input, output, parsed, separator, sepString, and stack.

void parse IBuffer  input  ) 
 

Read all tokens. Everything is mapped rather than being allocated & copied

Reimplemented in HttpHeaders, and HttpParams.

Referenced by parse().

void parse char[]  content  )  [inline]
 

Parse an input string.

Definition at line 165 of file HttpTokens.d.

References input, parse(), and IBuffer::setValidContent().

void reset  )  [inline]
 

Reset this set of tokens.

Definition at line 177 of file HttpTokens.d.

References IBuffer::clear(), output, parsed, TokenStack::reset(), and stack.

Referenced by HttpClient::open(), and HttpClient::reset().

bool isParsed  )  [inline]
 

Have tokens been parsed yet?

Definition at line 193 of file HttpTokens.d.

References parsed.

void setParsed bool  parsed  )  [inline]
 

Indicate whether tokens have been parsed or not.

Definition at line 204 of file HttpTokens.d.

Referenced by HttpParams::parse(), and HttpHeaders::parse().

char [] get char[]  name,
char[]  ret = null
[inline]
 

Return the value of the provided header, or null if the header does not exist

Definition at line 216 of file HttpTokens.d.

References TokenStack::findToken(), split(), stack, trim(), and HttpToken::value.

Referenced by AdminServlet::addLogger(), getDate(), getInt(), AdminServlet::service(), and AdminServlet::setLoggerLevel().

int getInt char[]  name,
int  ret = -1
[inline]
 

Return the integer value of the provided header, or the provided default-vaule if the header does not exist

Definition at line 236 of file HttpTokens.d.

References get(), and Integer.

Referenced by AdminServlet::addLogger().

ulong getDate char[]  name,
ulong  date = Rfc1123.InvalidEpoch
[inline]
 

Return the date value of the provided header, or the provided default-value if the header does not exist

Definition at line 253 of file HttpTokens.d.

References get().

int opApply int(*)(inout HttpToken dg  )  [inline]
 

Iterate over the set of tokens

Definition at line 269 of file HttpTokens.d.

References split(), and stack.

void write IWriter  writer  )  [inline]
 

Output the token list to the provided writer

Reimplemented from IWritable.

Definition at line 290 of file HttpTokens.d.

References IWriter::cr(), IWriter::put(), stack, and Token::toString().

bool handleMissingSeparator char[]  s,
inout HttpToken  element
[inline, protected]
 

overridable method to handle the case where a token does not have a separator. Apparently, this can happen in HTTP usage

Reimplemented in HttpQueryParams.

Definition at line 308 of file HttpTokens.d.

Referenced by split().

private bool split Token  t,
inout HttpToken  element
[inline]
 

split basic token into an HttpToken

Definition at line 319 of file HttpTokens.d.

References emptyString, handleMissingSeparator(), inclusive, separator, Text, and Token::toString().

Referenced by get(), HttpTokens::FilteredTokens::opApply(), and opApply().

FilteredTokens createFilter char[]  match  )  [inline]
 

Create a filter for iterating over the tokens matching a particular name.

Definition at line 349 of file HttpTokens.d.

bool isSpace char  c  )  [inline, private]
 

Is the argument a whitespace character?

Definition at line 411 of file HttpTokens.d.

Referenced by trim().

char [] trim char[]  source  )  [inline, private]
 

Trim the provided string by stripping whitespace from both ends. Returns a slice of the original content.

Definition at line 423 of file HttpTokens.d.

References isSpace().

Referenced by get().

void setOutputBuffer IBuffer  output  )  [inline, protected]
 

Set the output buffer for adding tokens to. This is used by the various MutableXXXX classes.

Definition at line 452 of file HttpTokens.d.

References output.

IBuffer getOutputBuffer  )  [inline, protected]
 

Return the buffer used for output.

Reimplemented in HttpMutableHeaders.

Definition at line 463 of file HttpTokens.d.

References output.

char [] toOutputString  )  [inline]
 

Return a char[] representing the output. An empty array is returned if output was not configured.

Definition at line 475 of file HttpTokens.d.

References output, and IBuffer::toString().

void add char[]  name,
void(*)(IBuffer dg
[inline, 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.

Definition at line 493 of file HttpTokens.d.

References IBuffer::append(), IBuffer::getLimit(), inclusive, output, TokenStack::push(), sepString, stack, and IBuffer::toString().

Referenced by add(), addDate(), and addInt().

void add char[]  name,
char[]  value
[inline, protected]
 

Add a simple name/value pair to the output

Reimplemented in HttpMutableParams.

Definition at line 519 of file HttpTokens.d.

References add(), and buffer.

void addInt char[]  name,
int  value
[inline, protected]
 

Add a name/integer pair to the output

Reimplemented in HttpMutableParams.

Definition at line 535 of file HttpTokens.d.

References add(), and Integer.

void addDate char[]  name,
ulong  value
[inline, protected]
 

Add a name/date(long) pair to the output

Reimplemented in HttpMutableParams.

Definition at line 549 of file HttpTokens.d.

References add().


Member Data Documentation

TokenStack stack [protected]
 

Definition at line 86 of file HttpTokens.d.

Referenced by add(), get(), HttpTokens::FilteredTokens::opApply(), opApply(), reset(), this(), and write().

IBuffer input [private]
 

Definition at line 88 of file HttpTokens.d.

Referenced by parse(), and this().

IBuffer output [private]
 

Definition at line 88 of file HttpTokens.d.

Referenced by add(), getOutputBuffer(), reset(), setOutputBuffer(), this(), and toOutputString().

bool parsed [private]
 

Definition at line 90 of file HttpTokens.d.

Referenced by isParsed(), reset(), and this().

bool inclusive [private]
 

Definition at line 91 of file HttpTokens.d.

Referenced by add(), split(), and this().

char separator [private]
 

Definition at line 92 of file HttpTokens.d.

Referenced by split(), and this().

char [1] sepString [private]
 

Definition at line 93 of file HttpTokens.d.

Referenced by add(), and this().

char [] emptyString [static, private]
 

Definition at line 94 of file HttpTokens.d.

Referenced by split(), and this().


The documentation for this class was generated from the following file:
Generated on Sat Dec 24 17:28:39 2005 for Mango by  doxygen 1.4.0