#include <request.hpp>
Public Member Functions | |
request ()=default | |
request (http::method_t method, std::string host, std::string url) | |
http::method_t | method () const |
std::string | url () const |
std::string | fragment () const |
http::version | version () const |
std::string | host () const |
bool | add_header (const std::string &header, const std::string &value) |
bool | remove_header (const std::string &header) |
const http::content & | content () const |
const t_string_param_map & | headers () const |
const t_string_param_map & | path_params () const |
const t_string_param_map & | query_params () const |
const t_string_param_map & | form_data () const |
const std::string & | body () const |
void | body (const std::string &content) |
std::list< matador::buffer_view > | to_buffers () const |
Friends | |
class | request_parser |
class | route_endpoint |
The request class bundles all information of a HTTP request to send.
|
default |
Default constructor
matador::http::request::request | ( | http::method_t | method, |
std::string | host, | ||
std::string | url | ||
) |
Initializes a request with the given HTTP method, host and port.
method | HTTP method |
host | Host of the request |
url | Port of the request |
bool matador::http::request::add_header | ( | const std::string & | header, |
const std::string & | value | ||
) |
Adds a HTTP header to the request consisting of the header key and the header value.
header | The header key name |
value | The value of the key |
const std::string & matador::http::request::body | ( | ) | const |
Returns the raw body as string.
void matador::http::request::body | ( | const std::string & | content | ) |
Sets the body of the request.
content | The body content to set |
const http::content & matador::http::request::content | ( | ) | const |
returns the content information of the request consisting of
const t_string_param_map & matador::http::request::form_data | ( | ) | const |
Return the form data map of the request.
std::string matador::http::request::fragment | ( | ) | const |
Returns the fragment of the request. This is the anchor part in the URL i.e. http://localhost/page#fragment
const t_string_param_map & matador::http::request::headers | ( | ) | const |
Return the requests HTTP header.
std::string matador::http::request::host | ( | ) | const |
Returns the host of the request.
http::method_t matador::http::request::method | ( | ) | const |
Returns the HTTP method of the request
const t_string_param_map & matador::http::request::path_params | ( | ) | const |
Return the requets path param map. If the url has captures for path params they are store in the path param map and can be obtained by their name.
const t_string_param_map & matador::http::request::query_params | ( | ) | const |
Return the requests HTTP query params as a key value map.
bool matador::http::request::remove_header | ( | const std::string & | header | ) |
Removes a header identified by the given header key from the request.
header | Key of the header to remove |
std::list< matador::buffer_view > matador::http::request::to_buffers | ( | ) | const |
Creates a list of view buffer containing the request ready to be send.
std::string matador::http::request::url | ( | ) | const |
Returns the URL of the request.
http::version matador::http::request::version | ( | ) | const |
Returns the requests HTTP version.