A http client class. More...
#include <http_client.hpp>
Public Member Functions | |
client (const std::string &host) | |
response | get (const std::string &route) |
response | post (const std::string &route, const std::string &body) |
response | put (const std::string &route, const std::string &body) |
response | remove (const std::string &route) |
A http client class.
This class represents a http client connection. The class is initialized with the remote endpoint url consisting of a hostname or ip address and optional a port <host[:port]>.
It provides the four main http commands
Once on of the four command is called via provided method a connection is established and the request is send synchronously.
Once the answer is received and processed a response object is returned.
|
explicit |
Creates a client for the given host
host | Host and optional port string |
response matador::http::client::get | ( | const std::string & | route | ) |
Sends a GET request to the given route at the configured host.
route | Route to be requested |
response matador::http::client::post | ( | const std::string & | route, |
const std::string & | body | ||
) |
Sends a POST request to the given route at the configured host with the given body as string.
route | Route to be requested |
body | String representing the body of the request |
response matador::http::client::put | ( | const std::string & | route, |
const std::string & | body | ||
) |
Sends a PUT request to the given route at the configured host with the given body as string.
route | Route to be requested |
body | String representing the body of the request |
response matador::http::client::remove | ( | const std::string & | route | ) |
Sends a DELETE request to the given route at the configured host.
route | Route to be requested |