#include <http_client.hpp>
|
| using | Request = http::request<http::string_body> |
| using | Response = http::response<http::string_body> |
| using | ResponseCallback = std::function<void(boost::system::result<http::response<http::string_body>> response)> |
| | Callback type for async requests.
|
|
| virtual | ~HttpClientBase ()=default |
| virtual void | set_host (const boost::urls::url &url)=0 |
| | Sets the host to connect to.
|
| virtual void | set_host (std::string_view url)=0 |
| | Sets the host to connect to.
|
| virtual void | set_host (std::string_view host, std::string_view service)=0 |
| | Sets the host to connect to.
|
| virtual void | get_async (std::string_view target, ResponseCallback callback)=0 |
| | Asynchronous GET request.
|
| virtual void | post_async (std::string_view target, std::string body, ResponseCallback callback, std::string_view content_type)=0 |
| | Asynchronous POST request to the target of the URL, or the root if no target is specified.
|
| virtual void | delete_async (std::string_view target, ResponseCallback callback)=0 |
| | Asynchronous DELETE request to the target of the URL, or the root if no target is specified.
|
| virtual void | request_async (http::verb method, std::string_view target, std::string body, std::string_view content_type, ResponseCallback callback)=0 |
| | Asynchronous request.
|
| virtual void | cancel_outstanding_requests ()=0 |
| | Clears all scheduled requests if there are any.
|
| virtual const std::string & | get_host () const =0 |
| virtual const std::string & | get_service () const =0 |
|
| static constexpr auto | k_default_port = "80" |
| | When no port is specified in the urls, the default port is used.
|
Definition at line 40 of file http_client.hpp.
◆ Request
◆ Response
◆ ResponseCallback
◆ ~HttpClientBase()
| virtual rav::HttpClientBase::~HttpClientBase |
( |
| ) |
|
|
virtualdefault |
◆ cancel_outstanding_requests()
| virtual void rav::HttpClientBase::cancel_outstanding_requests |
( |
| ) |
|
|
pure virtual |
Clears all scheduled requests if there are any.
Otherwise, this function has no effect.
Implemented in rav::HttpClient.
◆ delete_async()
| virtual void rav::HttpClientBase::delete_async |
( |
std::string_view | target, |
|
|
ResponseCallback | callback ) |
|
pure virtual |
Asynchronous DELETE request to the target of the URL, or the root if no target is specified.
- Parameters
-
| target | The target to request. |
| callback | The callback to call when the request is complete. |
Implemented in rav::HttpClient.
◆ get_async()
| virtual void rav::HttpClientBase::get_async |
( |
std::string_view | target, |
|
|
ResponseCallback | callback ) |
|
pure virtual |
Asynchronous GET request.
The callback's lifetime will be tied to the io_context so make sure referenced objects are kept alive until the callback is called.
- Parameters
-
| target | The target to request. |
| callback | The callback to call when the request is complete. |
Implemented in rav::HttpClient.
◆ get_host()
| virtual const std::string & rav::HttpClientBase::get_host |
( |
| ) |
const |
|
nodiscardpure virtual |
- Returns
- The host that is currently set for this client.
Implemented in rav::HttpClient.
◆ get_service()
| virtual const std::string & rav::HttpClientBase::get_service |
( |
| ) |
const |
|
nodiscardpure virtual |
- Returns
- The service (port) that this current client is set for this client.
Implemented in rav::HttpClient.
◆ post_async()
| virtual void rav::HttpClientBase::post_async |
( |
std::string_view | target, |
|
|
std::string | body, |
|
|
ResponseCallback | callback, |
|
|
std::string_view | content_type ) |
|
pure virtual |
Asynchronous POST request to the target of the URL, or the root if no target is specified.
- Parameters
-
| target | The target to request. |
| body | The body to send with the request. |
| callback | The callback to call when the request is complete. |
| content_type | The content type of the body, e.g. "application/json". If not specified, defaults to "application/json". |
Implemented in rav::HttpClient.
◆ request_async()
| virtual void rav::HttpClientBase::request_async |
( |
http::verb | method, |
|
|
std::string_view | target, |
|
|
std::string | body, |
|
|
std::string_view | content_type, |
|
|
ResponseCallback | callback ) |
|
pure virtual |
Asynchronous request.
- Parameters
-
| method | The HTTP method to use for the request. |
| target | The target to request. |
| body | The optional body to send with the request. |
| content_type | |
| callback | The callback to call when the request is complete. |
Implemented in rav::HttpClient.
◆ set_host() [1/3]
| virtual void rav::HttpClientBase::set_host |
( |
const boost::urls::url & | url | ) |
|
|
pure virtual |
Sets the host to connect to.
- Parameters
-
| url | The url with the host info. |
Implemented in rav::HttpClient.
◆ set_host() [2/3]
| virtual void rav::HttpClientBase::set_host |
( |
std::string_view | host, |
|
|
std::string_view | service ) |
|
pure virtual |
Sets the host to connect to.
- Parameters
-
| host | The host to connect to. |
| service | The service (port) to connect to. |
Implemented in rav::HttpClient.
◆ set_host() [3/3]
| virtual void rav::HttpClientBase::set_host |
( |
std::string_view | url | ) |
|
|
pure virtual |
Sets the host to connect to.
- Parameters
-
| url | The host to connect to. |
Implemented in rav::HttpClient.
◆ k_default_port
| auto rav::HttpClientBase::k_default_port = "80" |
|
staticconstexpr |
When no port is specified in the urls, the default port is used.
Definition at line 45 of file http_client.hpp.
The documentation for this class was generated from the following file: