|
RAVENNAKIT
|
A high level wrapper around boost::beast for making HTTP requests. More...
#include <http_client.hpp>
Public Member Functions | |
| HttpClient (boost::asio::io_context &io_context, std::chrono::milliseconds timeout_seconds=std::chrono::seconds(30)) | |
| Constructs a new HttpClient using the given io_context, but no url. | |
| HttpClient (boost::asio::io_context &io_context, std::string_view url, std::chrono::milliseconds timeout_seconds=std::chrono::seconds(30)) | |
| Constructs a new HttpClient using the given io_context and url. | |
| HttpClient (boost::asio::io_context &io_context, const boost::urls::url &url, std::chrono::milliseconds timeout_seconds=std::chrono::seconds(30)) | |
| Constructs a new HttpClient using the given io_context and url. | |
| HttpClient (boost::asio::io_context &io_context, const boost::asio::ip::tcp::endpoint &endpoint, std::chrono::milliseconds timeout_seconds=std::chrono::seconds(30)) | |
| Constructs a new HttpClient using the given io_context and url. | |
| HttpClient (boost::asio::io_context &io_context, const boost::asio::ip::address &address, uint16_t port, std::chrono::milliseconds timeout_seconds=std::chrono::seconds(30)) | |
| Constructs a new HttpClient using the given io_context and url. | |
| ~HttpClient () override | |
| HttpClient (const HttpClient &)=delete | |
| HttpClient & | operator= (const HttpClient &)=delete |
| HttpClient (HttpClient &&)=delete | |
| HttpClient & | operator= (HttpClient &&)=delete |
| void | set_host (const boost::urls::url &url) override |
| Sets the host to connect to. | |
| void | set_host (std::string_view url) override |
| Sets the host to connect to. | |
| void | set_host (std::string_view host, std::string_view service) override |
| Sets the host to connect to. | |
| void | get_async (std::string_view target, ResponseCallback callback) override |
| Asynchronous GET request. | |
| void | post_async (std::string_view target, std::string body, ResponseCallback callback, std::string_view content_type) override |
| Asynchronous POST request to the target of the URL, or the root if no target is specified. | |
| void | request_async (http::verb method, std::string_view target, std::string body, std::string_view content_type, ResponseCallback callback) override |
| Asynchronous request. | |
| void | delete_async (std::string_view target, ResponseCallback callback) override |
| Asynchronous DELETE request to the target of the URL, or the root if no target is specified. | |
| void | cancel_outstanding_requests () override |
| Clears all scheduled requests if there are any. | |
| const std::string & | get_host () const override |
| const std::string & | get_service () const override |
| Public Member Functions inherited from rav::HttpClientBase | |
| virtual | ~HttpClientBase ()=default |
Additional Inherited Members | |
| Public Types inherited from rav::HttpClientBase | |
| 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. | |
| Static Public Attributes inherited from rav::HttpClientBase | |
| static constexpr auto | k_default_port = "80" |
| When no port is specified in the urls, the default port is used. | |
A high level wrapper around boost::beast for making HTTP requests.
Definition at line 129 of file http_client.hpp.
|
explicit |
Constructs a new HttpClient using the given io_context, but no url.
| io_context | The io_context to use for the request. |
| timeout_seconds | The timeout in seconds for the requests. Defaults to 30 seconds. |
| rav::HttpClient::HttpClient | ( | boost::asio::io_context & | io_context, |
| std::string_view | url, | ||
| std::chrono::milliseconds | timeout_seconds = std::chrono::seconds(30) ) |
Constructs a new HttpClient using the given io_context and url.
| io_context | The io_context to use for the request. |
| url | The url to request. |
| timeout_seconds | The timeout in seconds for the requests. Defaults to 30 seconds. |
| rav::HttpClient::HttpClient | ( | boost::asio::io_context & | io_context, |
| const boost::urls::url & | url, | ||
| std::chrono::milliseconds | timeout_seconds = std::chrono::seconds(30) ) |
Constructs a new HttpClient using the given io_context and url.
| io_context | The io_context to use for the request. |
| url | The url to request. |
| timeout_seconds | The timeout in seconds for the requests. Defaults to 30 seconds. |
| rav::HttpClient::HttpClient | ( | boost::asio::io_context & | io_context, |
| const boost::asio::ip::tcp::endpoint & | endpoint, | ||
| std::chrono::milliseconds | timeout_seconds = std::chrono::seconds(30) ) |
Constructs a new HttpClient using the given io_context and url.
| io_context | The io_context to use for the request. |
| endpoint | The endpoint to request. |
| timeout_seconds | The timeout in seconds for the requests. Defaults to 30 seconds. |
| rav::HttpClient::HttpClient | ( | boost::asio::io_context & | io_context, |
| const boost::asio::ip::address & | address, | ||
| uint16_t | port, | ||
| std::chrono::milliseconds | timeout_seconds = std::chrono::seconds(30) ) |
Constructs a new HttpClient using the given io_context and url.
| io_context | The io_context to use for the request. |
| address | The address to request. |
| port | The port to request. |
| timeout_seconds | The timeout in seconds for the requests. Defaults to 30 seconds. |
|
override |
|
delete |
|
delete |
|
overridevirtual |
Clears all scheduled requests if there are any.
Otherwise, this function has no effect.
Implements rav::HttpClientBase.
|
overridevirtual |
Asynchronous DELETE request to the target of the URL, or the root if no target is specified.
| target | The target to request. |
| callback | The callback to call when the request is complete. |
Implements rav::HttpClientBase.
|
overridevirtual |
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.
| target | The target to request. |
| callback | The callback to call when the request is complete. |
Implements rav::HttpClientBase.
|
nodiscardoverridevirtual |
Implements rav::HttpClientBase.
|
nodiscardoverridevirtual |
Implements rav::HttpClientBase.
|
delete |
|
delete |
|
overridevirtual |
Asynchronous POST request to the target of the URL, or the root if no target is specified.
| 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". |
Implements rav::HttpClientBase.
|
overridevirtual |
Asynchronous request.
| 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. |
Implements rav::HttpClientBase.
|
overridevirtual |
Sets the host to connect to.
| url | The url with the host info. |
Implements rav::HttpClientBase.
|
overridevirtual |
Sets the host to connect to.
| url | The url with the host info. |
Implements rav::HttpClientBase.
|
overridevirtual |
Sets the host to connect to.
| url | The url with the host info. |
Implements rav::HttpClientBase.