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 () |
WebSocket * | getWebSocket () |
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" |
std::string HttpRequest::getHeader | ( | std::string | name | ) |
Get the named header.
[in] | name | The name of the header field to retrieve. |
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.
Socket HttpRequest::getSocket | ( | ) |
Get the underlying socket.
bool HttpRequest::isClosed | ( | ) |
Determine if the request is closed.
bool HttpRequest::isWebsocket | ( | ) |
Determine if this request represents a WebSocket.
std::map< std::string, std::string > HttpRequest::parseForm | ( | ) |
Parse the request message as a form.
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" ```
std::string HttpRequest::urlDecode | ( | std::string | str | ) |
Decode a URL/form.
[in] | str |