8 #ifndef COMPONENTS_CPP_UTILS_HTTPREQUEST_H_
9 #define COMPONENTS_CPP_UTILS_HTTPREQUEST_H_
14 #include "WebSocket.h"
15 #include "HttpParser.h"
23 static const char HTTP_HEADER_ACCEPT[];
24 static const char HTTP_HEADER_ALLOW[];
25 static const char HTTP_HEADER_CONNECTION[];
26 static const char HTTP_HEADER_CONTENT_LENGTH[];
27 static const char HTTP_HEADER_CONTENT_TYPE[];
28 static const char HTTP_HEADER_COOKIE[];
29 static const char HTTP_HEADER_HOST[];
30 static const char HTTP_HEADER_LAST_MODIFIED[];
31 static const char HTTP_HEADER_ORIGIN[];
32 static const char HTTP_HEADER_SEC_WEBSOCKET_ACCEPT[];
33 static const char HTTP_HEADER_SEC_WEBSOCKET_PROTOCOL[];
34 static const char HTTP_HEADER_SEC_WEBSOCKET_KEY[];
35 static const char HTTP_HEADER_SEC_WEBSOCKET_VERSION[];
36 static const char HTTP_HEADER_UPGRADE[];
37 static const char HTTP_HEADER_USER_AGENT[];
39 static const char HTTP_METHOD_CONNECT[];
40 static const char HTTP_METHOD_DELETE[];
41 static const char HTTP_METHOD_GET[];
42 static const char HTTP_METHOD_HEAD[];
43 static const char HTTP_METHOD_OPTIONS[];
44 static const char HTTP_METHOD_PATCH[];
45 static const char HTTP_METHOD_POST[];
46 static const char HTTP_METHOD_PUT[];
52 std::map<std::string, std::string> getHeaders();
53 std::string getMethod();
54 std::string getPath();
55 std::map<std::string, std::string>
getQuery();
57 std::string getVersion();
61 std::map<std::string, std::string>
parseForm();
bool isWebsocket()
Determine if this request represents a WebSocket.
Definition: HttpRequest.cpp:294
Encapsulate a socket.
Definition: Socket.h:62
Socket getSocket()
Get the underlying socket.
Definition: HttpRequest.cpp:266
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 keye...
Definition: HttpRequest.cpp:210
std::vector< std::string > pathSplit()
Return the constituent parts of the path. If we imagine a path as composed of parts separated by slas...
Definition: HttpRequest.cpp:346
Definition: WebSocket.h:60
std::string urlDecode(std::string str)
Decode a URL/form.
Definition: HttpRequest.cpp:366
std::string getBody()
Get the body of the HttpRequest.
Definition: HttpRequest.cpp:174
std::map< std::string, std::string > parseForm()
Parse the request message as a form.
Definition: HttpRequest.cpp:303
void dump()
Dump the HttpRequest for debugging purposes.
Definition: HttpRequest.cpp:160
Definition: HttpParser.h:14
void close()
Close the HttpRequest.
Definition: HttpRequest.cpp:148
Definition: HttpRequest.h:19
HttpRequest(Socket s)
Create an HTTP Request instance.
Definition: HttpRequest.cpp:95
bool isClosed()
Determine if the request is closed.
Definition: HttpRequest.cpp:285
std::string getHeader(std::string name)
Get the named header.
Definition: HttpRequest.cpp:184