tango.net.http.HttpCookies

License:

BSD style: see license.txt

Version:

Initial release: April 2004

Author:

Kris
class Cookie
Defines the Cookie class, and the means for reading & writing them. Cookie implementation conforms with RFC 2109, but supports parsing of server-side cookies only. Client-side cookies are supported in terms of output, but response parsing is not yet implemented ...
See over here for the RFC document.
this()
Construct an empty client-side cookie. You add these to an output request using HttpClient.addCookie(), or the equivalent.
this(const(char)[] name, const(char)[] value)
Construct a cookie with the provided attributes. You add these to an output request using HttpClient.addCookie(), or the equivalent.
Cookie setName(const(char)[] name)
Set the name of this cookie
Cookie setValue(const(char)[] value)
Set the value of this cookie
Cookie setVersion(uint vrsn)
Set the version of this cookie
Cookie setPath(const(char)[] path)
Set the path of this cookie
Cookie setDomain(const(char)[] domain)
Set the domain of this cookie
Cookie setComment(const(char)[] comment)
Set the comment associated with this cookie
Cookie setMaxAge(long maxAge)
Set the maximum duration of this cookie
Cookie setSecure(bool secure)
Indicate whether this cookie should be considered secure or not
void produce(scope size_t delegate(const(void)[]) consume)
Output the cookie as a text stream, via the provided consumer
Cookie clear()
Reset this cookie
class CookieStack
Implements a stack of cookies. Each cookie is pushed onto the stack by a parser, which takes its input from HttpHeaders. The stack can be populated for both client and server side cookies.
this(int size)
Construct a cookie stack with the specified initial extent. The stack will grow as necessary over time.
void reset() [final]
Pop the stack all the way to zero
Cookie push() [final]
Return a fresh cookie from the stack
int opApply(scope int delegate(ref Cookie) dg)
Iterate over all cookies in stack
class HttpCookiesView
This is the support point for server-side cookies. It wraps a CookieStack together with a set of HttpHeaders, along with the appropriate cookie parser. One would do something very similar for client side cookie parsing also.
this(HttpHeadersView headers)
Construct cookie wrapper with the provided headers.
void produce(scope size_t delegate(const(void)[]) consume, const(char)[] eol = Eol)
Output the token list to the provided consumer
void reset()
Reset these cookies for another parse
CookieStack parse()
Parse all cookies from our HttpHeaders, pushing each onto the CookieStack as we go.
class HttpCookies
Handles a set of output cookies by writing them into the list of output headers.
this(HttpHeaders headers, const(HttpHeaderName) name = SetCookie)
Construct an output cookie wrapper upon the provided output headers. Each cookie added is converted to an addition to those headers.
void add(Cookie cookie)
Add a cookie to our output headers.
class CookieParser : Iterator!(char)
Server-side cookie parser. See RFC 2109 for details.
static this() [shared]
populate a map of token separators
this(CookieStack stack)
size_t scan(const(void)[] data) [protected, override]
Callback for iterator.next(). We scan for name-value pairs, populating Cookie instances along the way.
bool parse(const(char)[] header)
Locate the next token from the provided buffer, and map a buffer reference into token. Returns true if a token was located, false otherwise.
Note that the buffer content is not duplicated. Instead, a slice of the buffer is referenced by the token. You can use Token.clone() or Token.toString().dup() to copy content per your application needs.

Note also that there may still be one token left in a buffer that was not terminated correctly (as in eof conditions). In such cases, tokens are mapped onto remaining content and the buffer will have no more readable content.
char[] toLower(ref char[] src) [static, final]
in-place conversion to lowercase