![]() |
zeep::http::request
// In header: <zeep/http/request.hpp> class request { public: // types typedef header param; typedef header cookie_directive; // construct/copy/destruct request(const std::string &, const std::string &, std::tuple< int, int > = { 1, 0 }, std::vector< header > && = {}, std::string && = {}); request(const request &); request & operator=(const request &); // friend functions friend std::ostream & operator<<(std::ostream &, const request &); // public member functions void set_local_endpoint(boost::asio::ip::tcp::socket &); std::tuple< std::string, uint16_t > get_local_endpoint() const; std::tuple< int, int > get_version() const; void set_method(const std::string &); const std::string & get_method() const; std::string get_uri() const; void set_uri(const std::string &); std::string get_path() const; std::string get_query() const; std::string get_host() const; std::string get_remote_address() const; const std::string & get_payload() const; void set_payload(const std::string &); boost::posix_time::ptime get_timestamp() const; float get_accept(const char *) const; bool keep_alive() const; void set_header(const char *, const std::string &); auto get_headers() const; std::string get_header(const char *) const; void remove_header(const char *); std::string get_pathname() const; json::element get_credentials() const; void set_credentials(json::element &&); std::string get_parameter(const char *) const; std::string get_parameter(const char *, const std::string &) const; template<typename T, typename std::enable_if_t< std::is_floating_point_v< T >, int > = 0> T get_parameter(const char *, const T &) const; template<typename T, typename std::enable_if_t< std::is_integral_v< T > and not std::is_same_v< T, bool >, int > = 0> T get_parameter(const char *, const T &) const; template<typename T, typename std::enable_if_t< std::is_same_v< T, bool >, int > = 0> T get_parameter(const char *, const T &) const; std::multimap< std::string, std::string > get_parameters() const; file_param get_file_parameter(const char *) const; std::vector< file_param > get_file_parameters(const char *) const; bool has_parameter(const char *) const; std::string get_cookie(const char *) const; std::string get_cookie(const std::string &) const; void set_cookie(const char *, const std::string &); std::vector< boost::asio::const_buffer > to_buffers() const; std::locale & get_locale() const; void set_content(const std::string &, const std::string &); void set_header(const std::string &, const std::string &); std::tuple< std::string, bool > get_parameter_ex(const char *) const; // private member functions void set_remote_address(const std::string &); };
request contains the parsed original HTTP request as received by the server.
request
friend functionsfriend std::ostream & operator<<(std::ostream & io, const request & req);For debugging purposes.
request
public member functionsvoid set_local_endpoint(boost::asio::ip::tcp::socket & socket);Fetch the local address from the connected socket.
std::tuple< std::string, uint16_t > get_local_endpoint() const;
std::tuple< int, int > get_version() const;Get the HTTP version requested.
void set_method(const std::string & method);Set the METHOD type (POST, GET, etc)
const std::string & get_method() const;Return the METHOD type (POST, GET, etc)
std::string get_uri() const;Return the original URI as requested.
void set_uri(const std::string & uri);Set the URI.
std::string get_path() const;Return the local path part of the request, after removing scheme, host and parameters.
std::string get_query() const;Return the parameter or query string, the part after the first question mark.
std::string get_host() const;Return the requested host.
std::string get_remote_address() const;Get the address of the connecting remote.
const std::string & get_payload() const;Return the payload.
void set_payload(const std::string & payload);Set the payload.
boost::posix_time::ptime get_timestamp() const;Return the time at which this request was received.
float get_accept(const char * type) const;Return the value in the Accept header for type.
bool keep_alive() const;Check for Connection: keep-alive header.
void set_header(const char * name, const std::string & value);Set or replace a named header.
auto get_headers() const;Return the list of headers.
std::string get_header(const char * name) const;Return the named header.
void remove_header(const char * name);Remove this header from the list of headers.
std::string get_pathname() const;Return the path part of the requested URI.
json::element get_credentials() const;Get the credentials. This is filled in if the request was validated.
void set_credentials(json::element && credentials);Set the credentials for the request.
std::string get_parameter(const char * name) const;Return the named parameter.
Fetch parameters from a request, either from the URL or from the payload in case the request contains a url-encoded or multi-part content-type header
std::string get_parameter(const char * name, const std::string & defaultValue) const;Return the value of the parameter named name or the defaultValue if this parameter was not found.
template<typename T, typename std::enable_if_t< std::is_floating_point_v< T >, int > = 0> T get_parameter(const char * name, const T & defaultValue) const;Return the value of the parameter named name or the defaultValue if this parameter was not found.
template<typename T, typename std::enable_if_t< std::is_integral_v< T > and not std::is_same_v< T, bool >, int > = 0> T get_parameter(const char * name, const T & defaultValue) const;Return the value of the parameter named name or the defaultValue if this parameter was not found.
template<typename T, typename std::enable_if_t< std::is_same_v< T, bool >, int > = 0> T get_parameter(const char * name, const T & defaultValue) const;Return the value of the parameter named name or the defaultValue if this parameter was not found.
std::multimap< std::string, std::string > get_parameters() const;Return a std::multimap of name/value pairs for all parameters.
file_param get_file_parameter(const char * name) const;Return the info for a file parameter with name name.
std::vector< file_param > get_file_parameters(const char * name) const;Return the info for all file parameters with name name.
bool has_parameter(const char * name) const;Return whether the named parameter is present in the request.
std::string get_cookie(const char * name) const;Return the value of HTTP Cookie with name name.
std::string get_cookie(const std::string & name) const;Return the value of HTTP Cookie with name name.
void set_cookie(const char * name, const std::string & value);Set the value of HTTP Cookie with name name to value.
std::vector< boost::asio::const_buffer > to_buffers() const;Return the content of this request in a sequence of const_buffers.
Can be used in code that sends HTTP requests
std::locale & get_locale() const;Return the Accept-Language header value in the request as a std::locale object.
void set_content(const std::string & text, const std::string & contentType);suppose we want to construct requests...
void set_header(const std::string & name, const std::string & value);set a header
std::tuple< std::string, bool > get_parameter_ex(const char * name) const;Return value and flag indicating the existence of a parameter named name.