matador::http::request Class Reference

#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::contentcontent () 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_viewto_buffers () const
 

Friends

class request_parser
 
class route_endpoint
 

Detailed Description

The request class bundles all information of a HTTP request to send.

Constructor & Destructor Documentation

◆ request() [1/2]

matador::http::request::request ( )
default

Default constructor

◆ request() [2/2]

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.

Parameters
methodHTTP method
hostHost of the request
urlPort of the request

Member Function Documentation

◆ add_header()

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.

Parameters
headerThe header key name
valueThe value of the key
Returns
True if the header was successfully added.

◆ body() [1/2]

const std::string & matador::http::request::body ( ) const

Returns the raw body as string.

Returns
The body of the request

◆ body() [2/2]

void matador::http::request::body ( const std::string &  content)

Sets the body of the request.

Parameters
contentThe body content to set

◆ content()

const http::content & matador::http::request::content ( ) const

returns the content information of the request consisting of

  • length
  • type
  • md5
  • language
Returns
The requests content information

◆ form_data()

const t_string_param_map & matador::http::request::form_data ( ) const

Return the form data map of the request.

Returns
The form data map

◆ fragment()

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

Returns
The fragment of the request

◆ headers()

const t_string_param_map & matador::http::request::headers ( ) const

Return the requests HTTP header.

Returns
The HTTP header

◆ host()

std::string matador::http::request::host ( ) const

Returns the host of the request.

Returns
The host of the request

◆ method()

http::method_t matador::http::request::method ( ) const

Returns the HTTP method of the request

Returns
The HTTP method

◆ path_params()

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.

Returns
The path parameter map

◆ query_params()

const t_string_param_map & matador::http::request::query_params ( ) const

Return the requests HTTP query params as a key value map.

Returns
The query parameter map

◆ remove_header()

bool matador::http::request::remove_header ( const std::string &  header)

Removes a header identified by the given header key from the request.

Parameters
headerKey of the header to remove
Returns
True if the header was successfully removed

◆ to_buffers()

std::list< matador::buffer_view > matador::http::request::to_buffers ( ) const

Creates a list of view buffer containing the request ready to be send.

Returns
List of buffer views containing the request ready to send

◆ url()

std::string matador::http::request::url ( ) const

Returns the URL of the request.

Returns
The URL of the request.

◆ version()

http::version matador::http::request::version ( ) const

Returns the requests HTTP version.

Returns
The used HTTP version

The documentation for this class was generated from the following file:
  • matador/http/request.hpp