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

Public Member Functions

 HttpRequest (Socket s)
 Create an HTTP Request instance.
 
void close ()
 Close the HttpRequest.
 
void dump ()
 Dump the HttpRequest for debugging purposes.
 
std::string getBody ()
 Get the body of the HttpRequest.
 
std::string getHeader (std::string name)
 Get the named header. More...
 
std::map< std::string,
std::string > 
getHeaders ()
 
std::string getMethod ()
 
std::string getPath ()
 
std::map< std::string,
std::string > 
getQuery ()
 Get the query part of the request. The query is a set of name = value pairs. The return is a map keyed by the name items. More...
 
Socket getSocket ()
 Get the underlying socket. More...
 
std::string getVersion ()
 
WebSocketgetWebSocket ()
 
bool isClosed ()
 Determine if the request is closed. More...
 
bool isWebsocket ()
 Determine if this request represents a WebSocket. More...
 
std::map< std::string,
std::string > 
parseForm ()
 Parse the request message as a form. More...
 
std::vector< std::string > pathSplit ()
 Return the constituent parts of the path. If we imagine a path as composed of parts separated by slashes, then this function returns a vector composed of the parts. For example: More...
 
std::string urlDecode (std::string str)
 Decode a URL/form. More...
 

Static Public Attributes

static const char HTTP_HEADER_ACCEPT [] = "Accept"
 
static const char HTTP_HEADER_ALLOW [] = "Allow"
 
static const char HTTP_HEADER_CONNECTION [] = "Connection"
 
static const char HTTP_HEADER_CONTENT_LENGTH [] = "Content-Length"
 
static const char HTTP_HEADER_CONTENT_TYPE [] = "Content-Type"
 
static const char HTTP_HEADER_COOKIE [] = "Cookie"
 
static const char HTTP_HEADER_HOST [] = "Host"
 
static const char HTTP_HEADER_LAST_MODIFIED [] = "Last-Modified"
 
static const char HTTP_HEADER_ORIGIN [] = "Origin"
 
static const char HTTP_HEADER_SEC_WEBSOCKET_ACCEPT [] = "Sec-WebSocket-Accept"
 
static const char HTTP_HEADER_SEC_WEBSOCKET_PROTOCOL [] = "Sec-WebSocket-Protocol"
 
static const char HTTP_HEADER_SEC_WEBSOCKET_KEY [] = "Sec-WebSocket-Key"
 
static const char HTTP_HEADER_SEC_WEBSOCKET_VERSION [] = "Sec-WebSocket-Version"
 
static const char HTTP_HEADER_UPGRADE [] = "Upgrade"
 
static const char HTTP_HEADER_USER_AGENT [] = "User-Agent"
 
static const char HTTP_METHOD_CONNECT [] = "CONNECT"
 
static const char HTTP_METHOD_DELETE [] = "DELETE"
 
static const char HTTP_METHOD_GET [] = "GET"
 
static const char HTTP_METHOD_HEAD [] = "HEAD"
 
static const char HTTP_METHOD_OPTIONS [] = "OPTIONS"
 
static const char HTTP_METHOD_PATCH [] = "PATCH"
 
static const char HTTP_METHOD_POST [] = "POST"
 
static const char HTTP_METHOD_PUT [] = "PUT"
 

Member Function Documentation

std::string HttpRequest::getHeader ( std::string  name)

Get the named header.

Parameters
[in]nameThe name of the header field to retrieve.
Returns
The value of the header field.
std::map< std::string, std::string > HttpRequest::getQuery ( )

Get the query part of the request. The query is a set of name = value pairs. The return is a map keyed by the name items.

Returns
The query part of the request.
Socket HttpRequest::getSocket ( )

Get the underlying socket.

Returns
The underlying socket.
bool HttpRequest::isClosed ( )

Determine if the request is closed.

Returns
Returns true if the request is closed.
bool HttpRequest::isWebsocket ( )

Determine if this request represents a WebSocket.

Returns
True if the request creates a web socket.
std::map< std::string, std::string > HttpRequest::parseForm ( )

Parse the request message as a form.

Returns
A map containing the names/values of the form elements that were found.
std::vector< std::string > HttpRequest::pathSplit ( )

Return the constituent parts of the path. If we imagine a path as composed of parts separated by slashes, then this function returns a vector composed of the parts. For example:

``` /x/y/z ``` will break out to:

``` path[0] = "" path[1] = "x" path[2] = "y" path[3] = "z" ```

Returns
A vector of the constituent parts of the path.
std::string HttpRequest::urlDecode ( std::string  str)

Decode a URL/form.

Parameters
[in]str
Returns
The decoded string.

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