HTTP request message. More...

#include <tnt/httprequest.h>

Inheritance diagram for tnt::HttpRequest:
tnt::HttpMessage

Classes

class  Parser

Public Types

typedef std::map< std::string,
std::string > 
args_type
- Public Types inherited from tnt::HttpMessage
typedef Messageheader header_type

Public Member Functions

 HttpRequest (Tntnet &application, const SocketIf *socketIf=0)
 HttpRequest (Tntnet &application, const std::string &url, const SocketIf *socketIf=0)
 HttpRequest (const HttpRequest &r)
 ~HttpRequest ()
HttpRequestoperator= (const HttpRequest &r)
void clear ()
 Remove all request-specific content.
const std::string & getBody () const
 Get the body of the message.
void setBody (const std::string &body)
 Set the body of the message.
bool isMethodGET () const
 Check whether http method used is GET.
bool isMethodPOST () const
 Check whether http method used is POST.
bool isMethodHEAD () const
 Check whether http method used is HEAD.
void setMethod (const char *_method)
 Set the http method of this request.
std::string getQuery () const
 Get url with GET parameters.
const std::string & getUrl () const
 Get the request url without GET parameters.
const std::string & getQueryString () const
 Get the query string (GET parameters string)
void setQueryString (const std::string &queryString)
 Set the query string.
void setPathInfo (const std::string &p)
const std::string & getPathInfo () const
void setArgs (const args_type &a)
const args_typegetArgs () const
args_typegetArgs ()
std::string getArg (const std::string &name, const std::string &def=std::string()) const
void parse (std::istream &in)
void doPostParse ()
const tnt::QueryParamsgetGetParams () const
 Get GET parameters.
const tnt::QueryParamsgetPostParams () const
 Get POST parameters.
void setQueryParams (const tnt::QueryParams &q)
 Set query parameters (GET and POST)
std::string getPeerIp () const
 Get the IP the request was sent from.
std::string getServerIp () const
 Get the IP the request was sent to.
bool isSsl () const
 Check whether the request was sent over an SSL (https) connection.
const ContenttypegetContentType () const
bool isMultipart () const
const MultipartgetMultipart () const
cxxtools::atomic_t getSerial () const
const std::locale & getLocale () const
const std::string & getLang () const
void setLocale (const std::locale &loc)
void setLang (const std::string &lang)
const CookiesgetCookies () const
bool hasCookie (const std::string &name) const
bool hasCookies () const
Cookie getCookie (const std::string &name) const
const EncodinggetEncoding () const
const char * getUserAgent () const
 Get the user agent (webbrowser) HTTP header.
const char * getHost () const
 Get the host (operating system) HTTP header.
const std::string & getUsername () const
 Get the HTTP-Auth username.
const std::string & getPassword () const
 Get the HTTP-Auth password.
bool verifyPassword (const std::string &password) const
 Check equality of the HTTP-Auth password and the parameter.
bool keepAlive () const
bool acceptGzipEncoding () const
 Check whether the client accepts gzip compression.
void setApplicationScope (Scope *s)
void setApplicationScope (Scope &s)
void setSessionScope (Sessionscope *s)
void setSessionScope (Sessionscope &s)
void setSecureSessionScope (Sessionscope *s)
void setSecureSessionScope (Sessionscope &s)
void setThreadContext (ThreadContext *ctx)
ScopegetRequestScope ()
ScopegetApplicationScope ()
ScopegetThreadScope ()
SessionscopegetSessionScope ()
SessionscopegetSecureSessionScope ()
bool hasSessionScope () const
bool hasSecureSessionScope () const
size_t getContentSize () const
 Get the value of the content-size HTTP header.
std::string getVirtualHost () const
 Get the virtual-host HTTP header.
TntnetgetApplication ()
void touch ()
 Rewind watchdog timer.
std::string getMethod () const
const char * getMethod_cstr () const
std::string getArgDef (args_type::size_type n, const std::string &def=std::string()) const
std::string getArg (args_type::size_type n) const
args_type::size_type getArgsCount () const
tnt::QueryParamsgetQueryParams ()
const tnt::QueryParamsgetQueryParams () const
- Public Member Functions inherited from tnt::HttpMessage
 HttpMessage ()
virtual ~HttpMessage ()
const char * getHeader (const char *key, const char *def="") const
 Get the content of the specified header if it is set, the passed default otherwise.
unsigned short getMajorVersion () const
 Get the major http version number.
unsigned short getMinorVersion () const
 Get the minor http version number.
void setVersion (unsigned short majorVersion, unsigned short minorVersion)
 Set the http version number.
header_type::const_iterator header_begin () const
 Get a constant iterator which points to the first header.
header_type::const_iterator header_end () const
 Get a constant iterator which points past the last header.
void setHeader (const std::string &key, const std::string &value, bool replace=true)
 Add the specified header to the message.
void removeHeader (const std::string &key)
 Remove the specified header from the message.
std::string dumpHeader () const
 Get all headers in one string.
void dumpHeader (std::ostream &out) const
 Print all headers to the specified output stream.
bool hasHeader (const char *key) const
bool hasHeader (const std::string &key) const

Static Public Member Functions

static void postRunCleanup ()
- Static Public Member Functions inherited from tnt::HttpMessage
static std::string htdateCurrent ()
 Get a string for the current time, formatted as needed in http.
static void htdateCurrent (char *current)
 Get a string for the current time, formatted as needed in http buffer must point to at least 30 bytes.
static bool checkUrl (const std::string &url)
 Check for double-dot-url.
static std::string htdate (time_t t)
static std::string htdate (const struct::tm *tm)
static void htdate (char *date, time_t t)
static void htdate (char *date, const struct::tm *tm)

Friends

class SessionUnlocker
class ApplicationUnlocker

Additional Inherited Members

- Protected Attributes inherited from tnt::HttpMessage
header_type header
Cookies httpcookies

Detailed Description

HTTP request message.

Member Typedef Documentation

typedef std::map<std::string, std::string> tnt::HttpRequest::args_type

Constructor & Destructor Documentation

tnt::HttpRequest::HttpRequest ( Tntnet application,
const SocketIf *  socketIf = 0 
)
explicit
tnt::HttpRequest::HttpRequest ( Tntnet application,
const std::string &  url,
const SocketIf *  socketIf = 0 
)
tnt::HttpRequest::HttpRequest ( const HttpRequest r)
tnt::HttpRequest::~HttpRequest ( )

Member Function Documentation

bool tnt::HttpRequest::acceptGzipEncoding ( ) const
inline

Check whether the client accepts gzip compression.

void tnt::HttpRequest::clear ( )
virtual

Remove all request-specific content.

Reimplemented from tnt::HttpMessage.

void tnt::HttpRequest::doPostParse ( )
Tntnet& tnt::HttpRequest::getApplication ( )
inline
Scope& tnt::HttpRequest::getApplicationScope ( )
std::string tnt::HttpRequest::getArg ( args_type::size_type  n) const
inline
std::string tnt::HttpRequest::getArg ( const std::string &  name,
const std::string &  def = std::string() 
) const
std::string tnt::HttpRequest::getArgDef ( args_type::size_type  n,
const std::string &  def = std::string() 
) const
const args_type& tnt::HttpRequest::getArgs ( ) const
inline
args_type& tnt::HttpRequest::getArgs ( )
inline
args_type::size_type tnt::HttpRequest::getArgsCount ( ) const
inline
const std::string& tnt::HttpRequest::getBody ( ) const
inline

Get the body of the message.

size_t tnt::HttpRequest::getContentSize ( ) const
inline

Get the value of the content-size HTTP header.

const Contenttype& tnt::HttpRequest::getContentType ( ) const
inline
Cookie tnt::HttpRequest::getCookie ( const std::string &  name) const
inline
const Cookies& tnt::HttpRequest::getCookies ( ) const
const Encoding& tnt::HttpRequest::getEncoding ( ) const
const tnt::QueryParams& tnt::HttpRequest::getGetParams ( ) const
inline

Get GET parameters.

const char* tnt::HttpRequest::getHost ( ) const
inline

Get the host (operating system) HTTP header.

const std::string& tnt::HttpRequest::getLang ( ) const
inline
const std::locale& tnt::HttpRequest::getLocale ( ) const
std::string tnt::HttpRequest::getMethod ( ) const
inline

Get the http method of a request (usually GET or POST)

const char* tnt::HttpRequest::getMethod_cstr ( ) const
inline

Get the http method of a request (usually GET or POST)

const Multipart& tnt::HttpRequest::getMultipart ( ) const
inline
const std::string& tnt::HttpRequest::getPassword ( ) const

Get the HTTP-Auth password.

const std::string& tnt::HttpRequest::getPathInfo ( ) const
inline
std::string tnt::HttpRequest::getPeerIp ( ) const
inline

Get the IP the request was sent from.

const tnt::QueryParams& tnt::HttpRequest::getPostParams ( ) const
inline

Get POST parameters.

std::string tnt::HttpRequest::getQuery ( ) const
inline

Get url with GET parameters.

tnt::QueryParams& tnt::HttpRequest::getQueryParams ( )
inline

Get query parameters (GET and POST)

const tnt::QueryParams& tnt::HttpRequest::getQueryParams ( ) const
inline

Get query parameters (GET and POST)

const std::string& tnt::HttpRequest::getQueryString ( ) const
inline

Get the query string (GET parameters string)

Scope& tnt::HttpRequest::getRequestScope ( )
Sessionscope& tnt::HttpRequest::getSecureSessionScope ( )
cxxtools::atomic_t tnt::HttpRequest::getSerial ( ) const
inline
std::string tnt::HttpRequest::getServerIp ( ) const
inline

Get the IP the request was sent to.

Sessionscope& tnt::HttpRequest::getSessionScope ( )
Scope& tnt::HttpRequest::getThreadScope ( )
const std::string& tnt::HttpRequest::getUrl ( ) const
inline

Get the request url without GET parameters.

const char* tnt::HttpRequest::getUserAgent ( ) const
inline

Get the user agent (webbrowser) HTTP header.

const std::string& tnt::HttpRequest::getUsername ( ) const

Get the HTTP-Auth username.

std::string tnt::HttpRequest::getVirtualHost ( ) const
inline

Get the virtual-host HTTP header.

bool tnt::HttpRequest::hasCookie ( const std::string &  name) const
inline
bool tnt::HttpRequest::hasCookies ( ) const
inline
bool tnt::HttpRequest::hasSecureSessionScope ( ) const
bool tnt::HttpRequest::hasSessionScope ( ) const
bool tnt::HttpRequest::isMethodGET ( ) const
inline

Check whether http method used is GET.

bool tnt::HttpRequest::isMethodHEAD ( ) const
inline

Check whether http method used is HEAD.

bool tnt::HttpRequest::isMethodPOST ( ) const
inline

Check whether http method used is POST.

bool tnt::HttpRequest::isMultipart ( ) const
inline
bool tnt::HttpRequest::isSsl ( ) const
inline

Check whether the request was sent over an SSL (https) connection.

bool tnt::HttpRequest::keepAlive ( ) const
HttpRequest& tnt::HttpRequest::operator= ( const HttpRequest r)
void tnt::HttpRequest::parse ( std::istream &  in)
static void tnt::HttpRequest::postRunCleanup ( )
static
void tnt::HttpRequest::setApplicationScope ( Scope s)
void tnt::HttpRequest::setApplicationScope ( Scope s)
inline
void tnt::HttpRequest::setArgs ( const args_type a)
inline
void tnt::HttpRequest::setBody ( const std::string &  body)
inline

Set the body of the message.

void tnt::HttpRequest::setLang ( const std::string &  lang)
void tnt::HttpRequest::setLocale ( const std::locale &  loc)
void tnt::HttpRequest::setMethod ( const char *  _method)

Set the http method of this request.

void tnt::HttpRequest::setPathInfo ( const std::string &  p)
inline
void tnt::HttpRequest::setQueryParams ( const tnt::QueryParams q)
inline

Set query parameters (GET and POST)

void tnt::HttpRequest::setQueryString ( const std::string &  queryString)
inline

Set the query string.

void tnt::HttpRequest::setSecureSessionScope ( Sessionscope s)
void tnt::HttpRequest::setSecureSessionScope ( Sessionscope s)
inline
void tnt::HttpRequest::setSessionScope ( Sessionscope s)
void tnt::HttpRequest::setSessionScope ( Sessionscope s)
inline
void tnt::HttpRequest::setThreadContext ( ThreadContext *  ctx)
inline
void tnt::HttpRequest::touch ( )
inline

Rewind watchdog timer.

bool tnt::HttpRequest::verifyPassword ( const std::string &  password) const

Check equality of the HTTP-Auth password and the parameter.

Friends And Related Function Documentation

friend class ApplicationUnlocker
friend
friend class SessionUnlocker
friend

The documentation for this class was generated from the following file: