|
RADLib
RADical C++ application framework
|
Small libcurl-backed HTTP client with sync and event-loop async APIs. More...
#include <RADNet.h>
Inheritance diagram for RADNet::RADHttpClient:
Collaboration diagram for RADNet::RADHttpClient:Public Member Functions | |
| RADHttpClient (RADCore::EventLoop &loop) | |
| Creates an async client that posts results to loop. More... | |
| void | requestAsync (const RADHttpRequest &request) |
| Starts an async request and emits finished/errorOccurred. More... | |
| void | getAsync (const RADCore::RADUrl &url) |
| Starts an async GET request for url and emits finished/errorOccurred. More... | |
| void | getAsync (const std::string &url) |
| Parses url and starts an async GET request. More... | |
Public Member Functions inherited from RADCore::RADObject | |
| RADObject () | |
| Creates a RADObject bound to the current thread. More... | |
| virtual | ~RADObject () |
| Disconnects tracked event links and releases lifetime token. More... | |
| void | registerLink (const ConnectionRecord &record) |
| Registers a connection for cleanup when this object is destroyed. More... | |
| std::thread::id | threadId () const |
| Returns the thread id this object is currently associated with. More... | |
| EventLoop * | associatedEventLoop () const |
| Returns the associated event loop, if any. More... | |
| ThreadAffinity | threadAffinity () const |
| Returns both thread id and associated loop atomically. More... | |
| std::weak_ptr< void > | lifetimeToken () const |
| Returns a weak token used to drop queued callbacks after destruction. More... | |
| void | moveToThread (std::thread::id tId, EventLoop *loop=nullptr) |
| Moves the object's affinity to tId and optional loop. More... | |
Static Public Member Functions | |
| static std::optional< RADHttpResponse > | request (const RADHttpRequest &request, std::string *error=nullptr) |
| Performs a blocking HTTP request. More... | |
| static std::optional< RADHttpResponse > | get (const RADCore::RADUrl &url, std::string *error=nullptr) |
| Performs a blocking GET request for url. More... | |
| static std::optional< RADHttpResponse > | get (const std::string &url, std::string *error=nullptr) |
| Parses url and performs a blocking GET request. More... | |
| static std::optional< RADHttpResponse > | post (const std::string &url, const std::string &body, const std::map< std::string, std::string > &headers={}, std::string *error=nullptr) |
| Performs a blocking POST request. More... | |
| static RADDnsResult | resolve (const std::string &host) |
| Resolves host to address strings. More... | |
Public Attributes | |
| RADCore::Event< void(RADNet::RADHttpResponse) > | finished |
| Raised by async requests when a response completes. More... | |
| RADCore::Event< void(std::string) > | errorOccurred |
| Raised by async requests when request setup or transfer fails. More... | |
Small libcurl-backed HTTP client with sync and event-loop async APIs.
|
explicit |
Creates an async client that posts results to loop.
|
static |
Performs a blocking GET request for url.
|
static |
Parses url and performs a blocking GET request.
| void RADNet::RADHttpClient::getAsync | ( | const RADCore::RADUrl & | url | ) |
Starts an async GET request for url and emits finished/errorOccurred.
| void RADNet::RADHttpClient::getAsync | ( | const std::string & | url | ) |
Parses url and starts an async GET request.
|
static |
Performs a blocking POST request.
|
static |
Performs a blocking HTTP request.
| void RADNet::RADHttpClient::requestAsync | ( | const RADHttpRequest & | request | ) |
Starts an async request and emits finished/errorOccurred.
|
static |
Resolves host to address strings.
| RADCore::Event<void (std::string) > RADNet::RADHttpClient::errorOccurred |
Raised by async requests when request setup or transfer fails.
| RADCore::Event<void (RADNet::RADHttpResponse) > RADNet::RADHttpClient::finished |
Raised by async requests when a response completes.