A simple HTTP client.
More...
#include <HttpClient.hpp>
|
static std::unique_ptr< HttpClient > | newClient (const Resource::Url &url, std::string userAgent="Balau "+BalauVersion, const char *version="1.1") |
| Create a new HTTP or HTTPS client, according to the supplied URL. More...
|
|
static std::unique_ptr< HttpClient > | newClient (const std::string &url, std::string userAgent="Balau "+BalauVersion, const char *version="1.1") |
| Create a new HTTP or HTTPS client, according to the supplied URL string. More...
|
|
A simple HTTP client.
- Todo:
- Add chunked transfer.
◆ HttpClient() [1/3]
HttpClient |
( |
std::string |
host_, |
|
|
unsigned short |
port_ = 80 , |
|
|
std::string |
userAgent_ = "Balau " + BalauVersion , |
|
|
const char * |
version_ = "1.1" |
|
) |
| |
|
inlineexplicit |
Create an HTTP client instance.
- Parameters
-
host_ | the host name to connect to |
port_ | the port number to connect to |
userAgent_ | the user agent string to send |
version_ | either "1.0" or "1.1" (the default) |
◆ HttpClient() [2/3]
Create an HTTP client by copying the supplied instance.
◆ HttpClient() [3/3]
Create an HTTP client by moving the contents of the supplied instance.
◆ ~HttpClient()
Destroy the client instance.
◆ get()
Perform a GET request.
- Exceptions
-
NetworkException | if an invalid HTTP version was supplied to the client |
Reimplemented in HttpsClient.
◆ head()
Perform a HEAD request.
- Exceptions
-
NetworkException | if an invalid HTTP version was supplied to the client |
Reimplemented in HttpsClient.
◆ newClient() [1/2]
static std::unique_ptr<HttpClient> newClient |
( |
const Resource::Url & |
url, |
|
|
std::string |
userAgent = "Balau "+BalauVersion , |
|
|
const char * |
version = "1.1" |
|
) |
| |
|
static |
Create a new HTTP or HTTPS client, according to the supplied URL.
- Parameters
-
url | the url containing the scheme, host, and port information |
userAgent | the user agent string to send |
version | either "1.0" or "1.1" (the default) |
- Exceptions
-
InvalidUriException | if the URI is not well formed |
NetworkException | if host information is not provided in the URI or the scheme is not "http" or "https" |
◆ newClient() [2/2]
static std::unique_ptr<HttpClient> newClient |
( |
const std::string & |
url, |
|
|
std::string |
userAgent = "Balau "+BalauVersion , |
|
|
const char * |
version = "1.1" |
|
) |
| |
|
static |
Create a new HTTP or HTTPS client, according to the supplied URL string.
- Parameters
-
url | the url string containing the scheme, host, and port information |
userAgent | the user agent string to send |
version | either "1.0" or "1.1" (the default) |
- Exceptions
-
InvalidUriException | if the URI is not well formed |
NetworkException | if host information is not provided in the URI or the scheme is not "http" or "https" |
◆ operator=() [1/2]
Assign an HTTP client by copying the supplied instance.
◆ operator=() [2/2]
Assign an HTTP client by moving the contents of the supplied instance.
◆ post()
virtual CharVectorResponse post |
( |
const std::string_view & |
path, |
|
|
const std::string_view & |
body |
|
) |
| |
|
inlinevirtual |
Perform a POST request.
- Exceptions
-
NetworkException | if an invalid HTTP version was supplied to the client |
Reimplemented in HttpsClient.
The documentation for this class was generated from the following file: