My Project
 All Classes Functions Variables Pages
Public Member Functions | Static Public Attributes | List of all members
HttpResponse Class Reference

Public Member Functions

 HttpResponse (HttpRequest *httpRequest)
 
void addHeader (std::string name, std::string value)
 Add a header to the response message. If the response has already been committed then ignore this request. More...
 
void close ()
 Close the response. We close the response. If we haven't yet sent the header, we send that now and then close the socket.
 
std::string getHeader (std::string name)
 Get the value of the named header. More...
 
std::map< std::string,
std::string > 
getHeaders ()
 
void sendData (std::string data)
 Send data to the partner. Send some data to the partner. If we haven't yet sent the HTTP header then send that now. We can call this function any number of times before calling close. After calling close, we may not call this function again. More...
 
void sendData (uint8_t *pData, size_t size)
 
void setStatus (int status, std::string message)
 Set the status code that is to be sent back to the client. When a client makes a request, the response contains a status. This call sets the status that will be sent back to the client. More...
 
void sendFile (std::string fileName, size_t bufSize=4 *1024)
 

Static Public Attributes

static const int HTTP_STATUS_CONTINUE = 100
 
static const int HTTP_STATUS_SWITCHING_PROTOCOL = 101
 
static const int HTTP_STATUS_OK = 200
 
static const int HTTP_STATUS_MOVED_PERMANENTLY = 301
 
static const int HTTP_STATUS_BAD_REQUEST = 400
 
static const int HTTP_STATUS_UNAUTHORIZED = 401
 
static const int HTTP_STATUS_FORBIDDEN = 403
 
static const int HTTP_STATUS_NOT_FOUND = 404
 
static const int HTTP_STATUS_METHOD_NOT_ALLOWED = 405
 
static const int HTTP_STATUS_INTERNAL_SERVER_ERROR = 500
 
static const int HTTP_STATUS_NOT_IMPLEMENTED = 501
 
static const int HTTP_STATUS_SERVICE_UNAVAILABLE = 503
 

Member Function Documentation

void HttpResponse::addHeader ( std::string  name,
std::string  value 
)

Add a header to the response message. If the response has already been committed then ignore this request.

Parameters
[in]nameThe name of the header.
[in]valueThe value of the header.
std::string HttpResponse::getHeader ( std::string  name)

Get the value of the named header.

Parameters
[in]nameThe name of the header for which the value is to be returned.
Returns
The value of the named header.
void HttpResponse::sendData ( std::string  data)

Send data to the partner. Send some data to the partner. If we haven't yet sent the HTTP header then send that now. We can call this function any number of times before calling close. After calling close, we may not call this function again.

Parameters
[in]dataThe data to send to the partner.
void HttpResponse::setStatus ( int  status,
std::string  message 
)

Set the status code that is to be sent back to the client. When a client makes a request, the response contains a status. This call sets the status that will be sent back to the client.

Parameters
[in]statusThe status code to be sent back to the caller.
[in]messageThe message to be sent with the status code.

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