LuciadCPillar 2024.0.08
|
An HTTP Client, implementation of the luciad::IHttpClient
interface.
More...
#include <luciad/net/http/HttpClient.h>
Classes | |
class | Builder |
Builder for the luciad::HttpClient class. More... | |
Public Member Functions | |
~HttpClient () override | |
void | clearHttpRequestOptions () |
Clears the HTTP request options sent with every request, if any. More... | |
const std::optional< HttpRequestOptions > & | getHttpRequestOptions () const |
Returns the HTTP request options sent with every request. More... | |
luciad::expected< HttpResponse, ErrorInfo > | send (const HttpRequest &request) |
Returns the HTTP response for the given HTTP request . More... | |
luciad::expected< HttpResponse, ErrorInfo > | send (const HttpRequest &request, const CancellationToken &token) override |
Returns the HTTP response for the given HTTP request . More... | |
void | setHttpRequestOptions (HttpRequestOptions requestOptions) |
Sets the HTTP request options sent with every request. More... | |
Public Member Functions inherited from luciad::IHttpClient | |
virtual | ~IHttpClient ()=default |
virtual luciad::expected< HttpResponse, ErrorInfo > | send (const HttpRequest &request, const CancellationToken &token)=0 |
Returns the HTTP response for the given HTTP request . More... | |
Static Public Member Functions | |
static Builder | newBuilder () |
Creates the new HttpClient builder. More... | |
An HTTP Client, implementation of the luciad::IHttpClient
interface.
An HttpClient can be used to send requests and retrieve their responses. An HttpClient is created through a builder
. The builder can be used to configure client states, like: a proxy selector, an authenticator provider, etc.
This class is thread-safe, i.e. it can handle multiple concurrent requests.
|
override |
void luciad::HttpClient::clearHttpRequestOptions | ( | ) |
Clears the HTTP request options sent with every request, if any.
const std::optional< HttpRequestOptions > & luciad::HttpClient::getHttpRequestOptions | ( | ) | const |
Returns the HTTP request options sent with every request.
|
static |
Creates the new HttpClient builder.
luciad::expected< HttpResponse, ErrorInfo > luciad::HttpClient::send | ( | const HttpRequest & | request | ) |
Returns the HTTP response
for the given HTTP request
.
This method is synchronous and blocks until the request has been sent and the response has been received.
request | HTTP request. |
|
overridevirtual |
Returns the HTTP response
for the given HTTP request
.
This method is synchronous and blocks until the request has been sent and the response has been received.
The request process can be canceled by the means of the cancellation token
. It is up to the implementer to verify that the cancellation token state is set to true
during the operation. When set to true
this indicates that a HTTP response is no longer needed. The return value then can be an ErrorInfo
object with the error code Canceled
.
request | HTTP request. |
token | Cancellation token. |
Implements luciad::IHttpClient.
void luciad::HttpClient::setHttpRequestOptions | ( | HttpRequestOptions | requestOptions | ) |
Sets the HTTP request options sent with every request.
requestOptions | the request options. |