|
Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
|
Asynchronous HTTP/1.1 and HTTP/2 client (libcurl's multi interface). More...
#include <Client.hpp>
Public Member Functions | |
| Client (ClientOptions options={}) | |
| ~Client () | |
| Requests still in flight complete with error "client shut down". | |
| Client (const Client &)=delete | |
| Client & | operator= (const Client &)=delete |
| void | send (ClientRequest request, std::function< void(ClientResponse)> on_done) |
Starts request; on_done is called once, on the client's thread. | |
| ClientSendAwaiter | send_async (ClientRequest request) |
| Awaitable form of send(); the coroutine resumes on the client's thread. | |
| ClientResponse | send_sync (ClientRequest request) |
Sends request and waits for the response, blocking the calling thread (for code that cannot be asynchronous). | |
Static Public Member Functions | |
| static Client & | shared () |
| A process-wide client, created on first use. | |
Private Attributes | |
| std::unique_ptr< Impl > | impl_ |
Asynchronous HTTP/1.1 and HTTP/2 client (libcurl's multi interface).
One background thread drives every transfer, so many requests run at once without tying up worker threads, and connections are kept alive and reused between requests to the same host. Only http and https URLs are fetched, including on redirects, and TLS certificates are verified unless a request turns that off.
Completion callbacks, and coroutines resumed by send_async(), run on the client's thread: keep them short, and hand blocking work to a thread pool.
|
explicit |
| orbit::http::Client::~Client | ( | ) |
Requests still in flight complete with error "client shut down".
|
delete |
| void orbit::http::Client::send | ( | ClientRequest | request, |
| std::function< void(ClientResponse)> | on_done | ||
| ) |
Starts request; on_done is called once, on the client's thread.
|
inline |
Awaitable form of send(); the coroutine resumes on the client's thread.
| ClientResponse orbit::http::Client::send_sync | ( | ClientRequest | request | ) |
Sends request and waits for the response, blocking the calling thread (for code that cannot be asynchronous).
Called from the client's own thread (inside a completion callback) it would wait forever, so it fails at once instead.
|
static |
A process-wide client, created on first use.
|
private |