coeurl::Request struct

A HTTP request.

Can be sent using a Client You can listen to various events here and access the response, after it finished.

Public types

enum class Method { Delete, Get, Head, Options, Patch, Post, Put }
The different HTTP methods.

Constructors, destructors, conversion operators

Request(Client* client, Method method, std::string url)
construct a new request to url.
~Request()
Cleans up a request.
Request(Request const&) deleted
Uncopyable.
Request(Request&&) deleted
Unmoveable.

Public functions

void operator=(Request const&) deleted
Uncopyable.
void operator=(Request&&) deleted
Unmoveable.
auto max_redirects(long amount) -> Request&
The maximum number of redirects. Defaults to 0.
auto verify_peer(bool verify) -> Request&
Whether to verify the certificate of the peer. Defaults to whatever is set on the client (usually true).
auto request(std::string r, std::string contenttype = "application/octet-stream") -> Request&
The actual request body. contenttype defaults to "application/octet-stream".
auto request_headers(const Headers& h) -> Request&
Headers for this request.
auto connection_timeout(long t) -> Request&
Timeout connection after the specified amount of seconds, if the server stops sending acks.
auto on_complete(const std::function<void(const Request&)> handler) -> Request&
Optional completion handler.
auto on_upload_progress(std::function<void(size_t progress, size_t total)> handler) -> Request&
Optional upload progress handler.
auto on_download_progess(std::function<void(size_t progress, size_t total)> handler) -> Request&
Optional download progress handler.
auto url() const -> std::string_view
The url for this request.
auto response() const -> std::string_view
The response in this request.
auto response_code() const -> int
The HTTP response code. 200 for success.
auto error_code() const -> CURLcode
The curl error code. CURLE_OK (0) on success.
auto response_headers() const -> Headers
Headers for the response.

Enum documentation

enum class coeurl::Request::Method

The different HTTP methods.

Enumerators
Delete

HTTP DELETE.

Get

HTTP GET.

Head

HTTP HEAD.

Options

HTTP OPTIONS.

Patch

HTTP PATCH.

Post

HTTP POST.

Put

HTTP PUT.

Function documentation

coeurl::Request::Request(Client* client, Method method, std::string url)

construct a new request to url.

Parameters
client The client to use.
method The http method for this request. Usually GET.
url The URL to request.

Request& coeurl::Request::request_headers(const Headers& h)

Headers for this request.

Headers coeurl::Request::response_headers() const

Headers for the response.