Fawkes API
Fawkes Development Version
|
Web request meta data carrier. More...
#include <>>
Public Types | |
enum | Method { METHOD_CONNECT, METHOD_DELETE, METHOD_GET, METHOD_HEAD, METHOD_OPTIONS, METHOD_POST, METHOD_PUT, METHOD_TRACE, METHOD_PATCH } |
HTTP transfer methods. More... | |
enum | HttpVersion { HTTP_VERSION_1_0, HTTP_VERSION_1_1 } |
HTTP version. More... | |
Public Member Functions | |
WebRequest (const char *uri) | |
Constructor. More... | |
~WebRequest () | |
Destructor. More... | |
const std::string & | url () const |
Get URL. More... | |
const std::string & | uri () const |
Get URI. More... | |
Method | method () const |
Get HTTP transfer method. More... | |
const char * | method_str () const |
Get method as string. More... | |
HttpVersion | http_version () const |
Get HTTP version. More... | |
const char * | http_version_str () const |
Get HTTP version as string. More... | |
const Time & | time () const |
Get request time. More... | |
const std::string & | user () const |
Get name of authenticated user (basic auth). More... | |
const std::string & | client_addr () const |
Get client address as string. More... | |
const std::map< std::string, std::string > & | cookies () const |
Get map of cookies. More... | |
std::string | cookie (std::string &key) const |
Get specific cookie. More... | |
bool | has_cookie (std::string key) const |
Check if the named cookie has been received. More... | |
const std::map< std::string, std::string > & | post_values () const |
Get map of POST values. More... | |
std::string | post_value (std::string &key) const |
Get specific POST value. More... | |
std::string | post_value (const char *key) const |
Get specific POST value. More... | |
bool | has_post_value (std::string key) const |
Check if the named post value has been received. More... | |
const std::map< std::string, std::string > & | get_values () const |
Get map of GET values. More... | |
std::string | get_value (std::string &key) const |
Get specific GET value. More... | |
std::string | get_value (const char *key) const |
Get specific GET value. More... | |
bool | has_get_value (std::string key) const |
Check if the named get value has been received. More... | |
const std::map< std::string, std::string > & | headers () const |
Get map of header values. More... | |
std::string | header (std::string &key) const |
Header specific header value. More... | |
std::string | header (const char *key) const |
Get specific header value. More... | |
bool | has_header (std::string key) const |
Check if the named header value has been received. More... | |
void | set_cookie (const std::string &key, const std::string &value) |
Set a cookie. More... | |
void | set_post_value (const char *key, const char *data, size_t size) |
Set a POST value. More... | |
void | set_get_value (const std::string &key, const std::string &value) |
Set a GET value. More... | |
void | set_header (const std::string &key, const std::string &value) |
Set a header value. More... | |
std::string | path_arg (const std::string &what) const |
Get a path argument. More... | |
void | set_path_args (std::map< std::string, std::string > &&args) |
Set path arguments. More... | |
const std::string & | body () const |
Get body of request. More... | |
void | increment_reply_size (size_t increment_by) |
Increment reply bytes counter. More... | |
size_t | reply_size () const |
Get number of bytes actually sent out so far. More... | |
WebReply::Code | reply_code () const |
Get HTTP code of reply. More... | |
void | set_reply_code (WebReply::Code code) |
Set HTTP code of the final reply. More... | |
Protected Member Functions | |
void | set_cookies (const std::map< std::string, std::string > &cookies) |
Set cookie map. More... | |
void | set_body (const char *data, size_t data_size) |
Set request body. More... | |
void | addto_body (const char *data, size_t data_size) |
Add to request body. More... | |
void | finish_body () |
Finalize body handling. More... | |
Web request meta data carrier.
For incoming web requests this class is instantiate to carry the necessary information for carriers like URL, request method, or cookie and POST form values.
fawkes::WebRequest::WebRequest | ( | const char * | uri | ) |
fawkes::WebRequest::~WebRequest | ( | ) |
Destructor.
Definition at line 166 of file request.cpp.
|
protected |
Add to request body.
The data is copied as is without assuming a human-readable string or even just zero-termination.
data | data to copy |
data_size | size in bytes of @p data |
Definition at line 209 of file request.cpp.
|
inline |
Get body of request.
Definition at line 330 of file request.h.
Referenced by XmlRpcRequestProcessor::process_request(), and fawkes::WebviewRestApi::process_request().
|
inline |
Get client address as string.
Definition at line 118 of file request.h.
Referenced by fawkes::WebviewAccessLog::log().
|
inline |
|
inline |
Get map of cookies.
Definition at line 126 of file request.h.
Referenced by set_cookies().
|
protected |
Finalize body handling.
Check for zero termination of body, and if it does not exist, add it.
Definition at line 218 of file request.cpp.
|
inline |
|
inline |
|
inline |
Get map of GET values.
Definition at line 190 of file request.h.
Referenced by fawkes::WebviewRestApi::process_request().
|
inline |
|
inline |
|
inline |
Check if the named header value has been received.
key | key of the requested header |
Definition at line 256 of file request.h.
Referenced by fawkes::WebviewAccessLog::log(), and MetricsRequestProcessor::process_request().
|
inline |
|
inline |
Header specific header value.
key | key of the header value |
Definition at line 236 of file request.h.
Referenced by fawkes::WebviewAccessLog::log(), and MetricsRequestProcessor::process_request().
|
inline |
|
inline |
|
inline |
const char * fawkes::WebRequest::http_version_str | ( | ) | const |
Get HTTP version as string.
Definition at line 268 of file request.cpp.
Referenced by fawkes::WebviewAccessLog::log().
void fawkes::WebRequest::increment_reply_size | ( | size_t | increment_by | ) |
Increment reply bytes counter.
increment_by | number of bytes sent |
Definition at line 231 of file request.cpp.
Referenced by fawkes::dynamic_reply_data_cb().
|
inline |
Get HTTP transfer method.
Definition at line 84 of file request.h.
Referenced by fawkes::WebviewRouter< Handler >::find_handler(), XmlRpcRequestProcessor::process_request(), and fawkes::WebviewRestApi::process_request().
const char * fawkes::WebRequest::method_str | ( | ) | const |
Get method as string.
Definition at line 249 of file request.cpp.
References METHOD_CONNECT, METHOD_DELETE, METHOD_GET, METHOD_HEAD, METHOD_OPTIONS, METHOD_POST, METHOD_PUT, and METHOD_TRACE.
Referenced by fawkes::WebviewAccessLog::log().
|
inline |
|
inline |
|
inline |
|
inline |
WebReply::Code fawkes::WebRequest::reply_code | ( | ) | const |
Get HTTP code of reply.
Definition at line 290 of file request.cpp.
Referenced by fawkes::WebviewAccessLog::log().
size_t fawkes::WebRequest::reply_size | ( | ) | const |
Get number of bytes actually sent out so far.
Definition at line 240 of file request.cpp.
Referenced by fawkes::WebviewAccessLog::log().
|
protected |
Set request body.
The data is copied as is without assuming a human-readable string or even just zero-termination.
data | data to copy |
data_size | size in bytes of @p data |
Definition at line 197 of file request.cpp.
|
inline |
|
inlineprotected |
|
inline |
|
inline |
|
inline |
void fawkes::WebRequest::set_post_value | ( | const char * | key, |
const char * | data, | ||
size_t | size | ||
) |
Set a POST value.
key | key of the cookie |
data | incoming data |
size | size in bytes of data |
key | key of the value |
data | data of the value |
size | size in bytes of data |
Definition at line 180 of file request.cpp.
void fawkes::WebRequest::set_reply_code | ( | WebReply::Code | code | ) |
Set HTTP code of the final reply.
code | reply code |
Definition at line 281 of file request.cpp.
|
inline |
Get request time.
Definition at line 102 of file request.h.
Referenced by fawkes::WebviewAccessLog::log().
|
inline |
Get URI.
Definition at line 76 of file request.h.
Referenced by fawkes::WebviewAccessLog::log().
|
inline |
Get URL.
Definition at line 68 of file request.h.
Referenced by fawkes::WebviewRouter< Handler >::find_handler().
|
inline |
Get name of authenticated user (basic auth).
Definition at line 110 of file request.h.
Referenced by fawkes::WebviewAccessLog::log().