19 std::vector<std::pair<std::string, std::string>>
headers;
34 std::vector<std::pair<std::string, std::string>>
headers;
42 std::optional<std::string>
header(std::string_view name)
const;
Asynchronous HTTP/1.1 and HTTP/2 client (libcurl's multi interface).
Definition Client.hpp:81
static Client & shared()
A process-wide client, created on first use.
void send(ClientRequest request, std::function< void(ClientResponse)> on_done)
Starts request; on_done is called once, on the client's thread.
Client(ClientOptions options={})
~Client()
Requests still in flight complete with error "client shut down".
Client & operator=(const Client &)=delete
ClientResponse send_sync(ClientRequest request)
Sends request and waits for the response, blocking the calling thread (for code that cannot be asynch...
Client(const Client &)=delete
std::unique_ptr< Impl > impl_
Definition Client.hpp:110
ClientSendAwaiter send_async(ClientRequest request)
Awaitable form of send(); the coroutine resumes on the client's thread.
Definition Client.hpp:94
std::string user_agent
Definition Client.hpp:46
An outbound HTTP request for Client.
Definition Client.hpp:16
long max_redirects
Definition Client.hpp:25
size_t max_response_size
Larger bodies fail the request.
Definition Client.hpp:28
std::chrono::milliseconds connect_timeout
Definition Client.hpp:23
std::string ca_file
PEM bundle; empty = system store.
Definition Client.hpp:27
std::string url
http:// or https:// only
Definition Client.hpp:18
std::string method
Definition Client.hpp:17
std::string body
Definition Client.hpp:20
bool verify_tls
Certificate chain and host name.
Definition Client.hpp:26
std::vector< std::pair< std::string, std::string > > headers
Definition Client.hpp:19
bool follow_redirects
To http(s) URLs only.
Definition Client.hpp:24
std::chrono::milliseconds timeout
Whole request, redirects included.
Definition Client.hpp:22
The result of a ClientRequest.
Definition Client.hpp:32
std::string effective_url
After redirects.
Definition Client.hpp:36
std::string error
Empty on success.
Definition Client.hpp:37
bool ok() const
True if a response arrived (any status, including 4xx and 5xx).
Definition Client.hpp:40
std::vector< std::pair< std::string, std::string > > headers
Of the final response.
Definition Client.hpp:34
long status
0 if no response arrived
Definition Client.hpp:33
std::string body
Definition Client.hpp:35
std::optional< std::string > header(std::string_view name) const
The last header named name (case-insensitive).
co_await Client::send_async(...): resumes with the ClientResponse.
Definition Client.hpp:52
bool await_ready() const noexcept
Definition Client.hpp:57
void await_suspend(std::coroutine_handle<> h)
Definition Client.hpp:113
ClientRequest request
Definition Client.hpp:54
ClientResponse response
Definition Client.hpp:55
Client * client
Definition Client.hpp:53
ClientResponse await_resume()
Definition Client.hpp:59