Base class for HTTP messages. More...

#include <tnt/httpmessage.h>

Inheritance diagram for tnt::HttpMessage:
tnt::HttpError tnt::HttpReply tnt::HttpRequest tnt::MovedTemporarily tnt::NotAuthorized tnt::NotFoundException

Public Types

typedef Messageheader header_type

Public Member Functions

 HttpMessage ()
virtual ~HttpMessage ()
virtual void clear ()
 Remove all request-specific content.
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 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)

Protected Attributes

header_type header
Cookies httpcookies

Detailed Description

Base class for HTTP messages.

Member Typedef Documentation

Constructor & Destructor Documentation

tnt::HttpMessage::HttpMessage ( )
inline
virtual tnt::HttpMessage::~HttpMessage ( )
inlinevirtual

Member Function Documentation

static bool tnt::HttpMessage::checkUrl ( const std::string &  url)
static

Check for double-dot-url.

Returns
false if the url used as a filename would escape from the basedir
virtual void tnt::HttpMessage::clear ( )
virtual

Remove all request-specific content.

Reimplemented in tnt::HttpRequest.

std::string tnt::HttpMessage::dumpHeader ( ) const

Get all headers in one string.

void tnt::HttpMessage::dumpHeader ( std::ostream &  out) const

Print all headers to the specified output stream.

const char* tnt::HttpMessage::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 tnt::HttpMessage::getMajorVersion ( ) const
inline

Get the major http version number.

unsigned short tnt::HttpMessage::getMinorVersion ( ) const
inline

Get the minor http version number.

bool tnt::HttpMessage::hasHeader ( const char *  key) const
inline

Check whether the message has the specified header

bool tnt::HttpMessage::hasHeader ( const std::string &  key) const
inline

Check whether the message has the specified header

header_type::const_iterator tnt::HttpMessage::header_begin ( ) const
inline

Get a constant iterator which points to the first header.

The value type of the iterator is std::pair<std::string, std::string>

header_type::const_iterator tnt::HttpMessage::header_end ( ) const
inline

Get a constant iterator which points past the last header.

static std::string tnt::HttpMessage::htdate ( time_t  t)
static

Get a date string, formatted as needed in http

static std::string tnt::HttpMessage::htdate ( const struct::tm *  tm)
static

Get a date string, formatted as needed in http

static void tnt::HttpMessage::htdate ( char *  date,
time_t  t 
)
static

Get a date string, formatted as needed in http

static void tnt::HttpMessage::htdate ( char *  date,
const struct::tm *  tm 
)
static

Get a date string, formatted as needed in http

static std::string tnt::HttpMessage::htdateCurrent ( )
static

Get a string for the current time, formatted as needed in http.

static void tnt::HttpMessage::htdateCurrent ( char *  current)
static

Get a string for the current time, formatted as needed in http buffer must point to at least 30 bytes.

void tnt::HttpMessage::removeHeader ( const std::string &  key)
inline

Remove the specified header from the message.

void tnt::HttpMessage::setHeader ( const std::string &  key,
const std::string &  value,
bool  replace = true 
)
inline

Add the specified header to the message.

void tnt::HttpMessage::setVersion ( unsigned short  majorVersion,
unsigned short  minorVersion 
)
inline

Set the http version number.

Member Data Documentation

header_type tnt::HttpMessage::header
protected
Cookies tnt::HttpMessage::httpcookies
protected

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