EHS Embedded HTTP Server  1.5.0.132
HttpResponse Class Reference

This class represents what is sent back to the client. More...

#include <httpresponse.h>

+ Inheritance diagram for HttpResponse:
+ Collaboration diagram for HttpResponse:

List of all members.

Public Member Functions

 HttpResponse (int inResponseId, EHSConnection *ipoEHSConnection)
 Constructs a new instance.
virtual ~HttpResponse ()
 Destructor.
void SetBody (const char *ipsBody, size_t inBodyLength)
 Sets the body of this instance.
void SetCookie (CookieParameters &iroCookieParameters)
 Sets cookies for this response.
void SetResponseCode (ResponseCode code)
 Sets the response code for this response.
ResponseCode GetResponseCode ()
 Retrieves the status code of this this response.
StringCaseMap & GetHeaders ()
 Retrieves the headers of this this response.
StringList & GetCookies ()
 Retrieves the cookies of this this response.
void SetHeader (const std::string &name, const std::string &value)
 Sets an HTTP header.
void RemoveHeader (const std::string &name)
 Removes an HTTP header.
std::string GetStatusString ()
 Retrieves the status string of this this response.
void SetDate (time_t stamp)
 Sets the HTTP Date header.
void SetLastModified (time_t stamp)
 Sets the HTTP Last-Modified header.
std::string HttpTime (time_t stamp)
 Utility function for converting a UNIX timestamp into an RFC-conformant HTTP time string.

Static Public Member Functions

static HttpResponseError (ResponseCode code, int inResponseId, EHSConnection *ipoEHSConnection)
 Constructs a new standardized error response.
static HttpResponseError (ResponseCode code, HttpRequest *request)
 Constructs a new standardized error response.
static const char * GetPhrase (ResponseCode code)
 Helper function for translating response codes into the corresponding text message.

Detailed Description

This class represents what is sent back to the client.

It contains the actual body, any headers specified, and the response code.

Examples:

ehs_basicauth.cpp, ehs_exception.cpp, ehs_formtest.cpp, ehs_mirror.cpp, ehs_privport.cpp, ehs_test.cpp, ehs_testharness.cpp, ehs_uploader.cpp, and ehs_wsgate.cpp.


Constructor & Destructor Documentation

HttpResponse ( int  inResponseId,
EHSConnection ipoEHSConnection 
)

Constructs a new instance.

Parameters:
inResponseIdA unique Id (normally derived from the corresponding request Id).
ipoEHSConnectionThe connection, on which this response should be sent.

Member Function Documentation

static HttpResponse* Error ( ResponseCode  code,
int  inResponseId,
EHSConnection ipoEHSConnection 
) [static]

Constructs a new standardized error response.

Parameters:
codeThe HTTP error code.
inResponseIdA unique Id (normally derived from the corresponding request Id).
ipoEHSConnectionThe connection, on which this response should be sent.
Returns:
The new response.
Examples:
ehs_exception.cpp, and ehs_wsgate.cpp.
static HttpResponse* Error ( ResponseCode  code,
HttpRequest request 
) [static]

Constructs a new standardized error response.

Parameters:
codeThe HTTP error code.
requestThe http request to which this response refers. (Used for initializing the Id and the outgoing connection).
Returns:
The new response.
static const char* GetPhrase ( ResponseCode  code) [static]

Helper function for translating response codes into the corresponding text message.

Parameters:
codeThe HTTP result code to be translated.
Returns:
The text message, representing the provided result code.
std::string GetStatusString ( )

Retrieves the status string of this this response.

Returns:
The current status as "<i>number</i> <i>description</i>".
std::string HttpTime ( time_t  stamp)

Utility function for converting a UNIX timestamp into an RFC-conformant HTTP time string.

Parameters:
stampA UNIX timestamp, representing the desired time.
Returns:
A string, containing the HTTP time.
void RemoveHeader ( const std::string &  name) [inline]

Removes an HTTP header.

Parameters:
nameThe case insensitive name of the HTTP header to remove.
Examples:
ehs_wsgate.cpp.

Definition at line 146 of file httpresponse.h.

void SetBody ( const char *  ipsBody,
size_t  inBodyLength 
)

Sets the body of this instance.

Parameters:
ipsBodyThe content to set.
inBodyLengthThe length of the body. This parameter also sets the value of the Content-Length HTTP header.

Reimplemented from GenericResponse.

Examples:
ehs_basicauth.cpp, ehs_exception.cpp, ehs_formtest.cpp, ehs_mirror.cpp, ehs_privport.cpp, ehs_test.cpp, ehs_testharness.cpp, ehs_uploader.cpp, and ehs_wsgate.cpp.
void SetCookie ( CookieParameters &  iroCookieParameters)

Sets cookies for this response.

Parameters:
iroCookieParametersThe cookies to set.
Examples:
ehs_test.cpp, and ehs_uploader.cpp.
void SetDate ( time_t  stamp)

Sets the HTTP Date header.

Parameters:
stampA UNIX timestamp, representing the desired time.
void SetHeader ( const std::string &  name,
const std::string &  value 
) [inline]

Sets an HTTP header.

Parameters:
nameThe name of the HTTP header to set.
valueThe value of the HTTP header to set.
Examples:
ehs_basicauth.cpp, ehs_uploader.cpp, and ehs_wsgate.cpp.

Definition at line 137 of file httpresponse.h.

void SetLastModified ( time_t  stamp)

Sets the HTTP Last-Modified header.

Parameters:
stampA UNIX timestamp, representing the desired time.
void SetResponseCode ( ResponseCode  code) [inline]

Sets the response code for this response.

Parameters:
codeThe desired HTTP response code.

Definition at line 115 of file httpresponse.h.


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