Wexus2 0.20
wexus::HTTPReply Class Reference

#include <HTTP.h>

List of all members.

Classes

struct  ServerCookie

Public Types

typedef QMap< QString,
ServerCookie
ServerCookies

Public Member Functions

 HTTPReply (QTextStream &outstream)
 ~HTTPReply ()
void setStatus (int status)
int status (void) const
bool hasReply (void) const
void setContentType (const QString &type)
const QString & contentType (void) const
QTextStream & output (void)
const ServerCookies & cookies (void) const
ServerCookies & cookies (void)
void redirectTo (const QString &rawurl)

Static Public Member Functions

static const char * statusToString (int status)

Protected Attributes

QTextStream & dm_outs
int dm_status
bool dm_calledcommit
QString dm_contenttype
ServerCookies dm_servercookies

Detailed Description

A HTTP reply that is sent back to the client as a result of an HTTP request.

The status may be set via the constructor, and or changed via setStatus. In eithercase, a reply with a 0 status is invalid and cannot be commited (used).

Author:
Aleksander Demko

Constructor & Destructor Documentation

wexus::HTTPReply::HTTPReply ( QTextStream &  outstream)

Constructs an http reply, using the given stream and with the given status code.

If your handler wants to respond to a request, must call output() (and produce some output), setStatus() or both.

Author:
Aleksander Demko
wexus::HTTPReply::~HTTPReply ( )

This calls the commitHeader method if status is >0 AND commitHeader() has not yet been called.

Author:
Aleksander Demko

Member Function Documentation

const QString& wexus::HTTPReply::contentType ( void  ) const [inline]

Returns the currently set content type. The default content type is text/html.

Author:
Aleksander Demko
const ServerCookies& wexus::HTTPReply::cookies ( void  ) const [inline]

Returns the cookies sent by the client.

Author:
Aleksander Demko
ServerCookies& wexus::HTTPReply::cookies ( void  ) [inline]

Returns the cookies sent by the client. non-const version. Callers can fiddle with the cookie map for convience.

Author:
Aleksander Demko
bool wexus::HTTPReply::hasReply ( void  ) const [inline]

True is a reply has been status (status is non-zero)

Author:
Aleksander Demko
QTextStream& wexus::HTTPReply::output ( void  )

Returns a stream that you can use to write the reply body. This called commitHeader() before hand, if it hasn't been called already.

You may want to include wx/streamop.h

Author:
Aleksander Demko
void wexus::HTTPReply::redirectTo ( const QString &  rawurl)

Sets a cookie that will be sent to the client. There can be many of these.

This cannot be called after commitHeader() has been called.

Parameters:
namethe name of the cookie
valuethe value of the cookie
expiresthe expiry of the cookie, in "Wdy, DD-Mon-YYYY HH:MM:SS GMT" format. If empty, a "session cookie" will be created. Negative time values aparently delete cookies.
domainthe domain name of servers that this cookie will be sent to. May be empty ("same as caller"), and may also be a suffix (".example.com") I guess to specify a collection of servers
pathThe path prefix this cookie is good for. examples: "/" and "/accounts"
Author:
Aleksander Demko Redirects the user browser to the given url. This sets the status code too. output() cannot be called before (or after) this call.
Aleksander Demko
void wexus::HTTPReply::setContentType ( const QString &  type)

Sets the content type. The default content type is text/html.

Author:
Aleksander Demko
void wexus::HTTPReply::setStatus ( int  status)

Sets the current status code that will be returned. The default status is 0, unless output() is used, in which case it is 200.

Author:
Aleksander Demko
int wexus::HTTPReply::status ( void  ) const [inline]

Gets the current return status code. If its 0, it means unset (reply not set).

Author:
Aleksander Demko
static const char* wexus::HTTPReply::statusToString ( int  status) [static]

Converts a status code to a description, null if this is an unkown status code. Uses const char * to minimuze copies.

Author:
Aleksander Demko

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Enumerations Enumerator