#include <cofetch.h>
|
| | Client (net::io_context &io, size_t max_pooled_connections=kDefaultMaxPooledHandles) |
| | Construct a client driven by io.
|
| |
| | Client (const Client &)=delete |
| |
| Client & | operator= (const Client &)=delete |
| |
| | ~Client () |
| | Destroy the client.
|
| |
| template<typename CompletionToken > |
| auto | async_perform (Request req, CompletionToken &&token) |
| | Start a transfer described by req.
|
| |
| template<typename CompletionToken > |
| auto | async_get (std::string url, CompletionToken &&token) |
| |
| template<typename CompletionToken > |
| auto | async_post (std::string url, std::string body, CompletionToken &&token) |
| |
| RequestBuilder | request (std::string url) |
| | Start a fluent request chain: request(url).body(...).post(token).
|
| |
| int | pending_requests () const |
| |
- Examples
- example_cancellation.cpp, example_compression.cpp, example_concurrent.cpp, example_coroutine.cpp, example_errors.cpp, example_fluent.cpp, example_future.cpp, example_hello.cpp, example_http2.cpp, example_keepalive.cpp, example_reactors.cpp, example_redirects.cpp, example_sync.cpp, and example_tls.cpp.
◆ Client() [1/2]
| cofetch::Client::Client |
( |
net::io_context & |
io, |
|
|
size_t |
max_pooled_connections = kDefaultMaxPooledHandles |
|
) |
| |
|
inlineexplicit |
Construct a client driven by io.
max_pooled_connections caps the idle easy handles kept for reuse; raise it for servers that keep many connections hot at once (default 64).
◆ Client() [2/2]
| cofetch::Client::Client |
( |
const Client & |
| ) |
|
|
delete |
◆ ~Client()
| cofetch::Client::~Client |
( |
| ) |
|
|
inline |
Destroy the client.
Requests still in flight are dropped and their completion handlers are never invoked; prefer draining the io_context first.
◆ async_get()
template<typename CompletionToken >
| auto cofetch::Client::async_get |
( |
std::string |
url, |
|
|
CompletionToken && |
token |
|
) |
| |
|
inline |
- Examples
- example_cancellation.cpp, example_compression.cpp, example_concurrent.cpp, example_coroutine.cpp, example_errors.cpp, example_future.cpp, example_hello.cpp, example_http2.cpp, example_keepalive.cpp, example_reactors.cpp, and example_redirects.cpp.
◆ async_perform()
template<typename CompletionToken >
| auto cofetch::Client::async_perform |
( |
Request |
req, |
|
|
CompletionToken && |
token |
|
) |
| |
|
inline |
Start a transfer described by req.
Completion signature is void(std::error_code, Response): the error_code carries the CURLcode (curl_category) for transport failures and is empty otherwise; HTTP error statuses are not transport failures (check Response::is_ok()).
If the completion handler has an associated cancellation slot (asio::bind_cancellation_slot, asio::cancel_after, co_spawn's cancellation state, ...), emitting cancellation aborts the transfer and the handler completes with asio::error::operation_aborted.
◆ async_post()
template<typename CompletionToken >
| auto cofetch::Client::async_post |
( |
std::string |
url, |
|
|
std::string |
body, |
|
|
CompletionToken && |
token |
|
) |
| |
|
inline |
◆ operator=()
◆ pending_requests()
| int cofetch::Client::pending_requests |
( |
| ) |
const |
|
inline |
◆ request()
The documentation for this class was generated from the following file: