LuciadCPillar C# 2026.1.02
Loading...
Searching...
No Matches
Luciad.Net.Http.HttpClient Class Referencesealed

An HTTP Client, implementation of the IHttpClient interface. More...

Inheritance diagram for Luciad.Net.Http.HttpClient:
Luciad.Net.Http.IHttpClient

Classes

class  Builder
 Builder for the HttpClient class. More...

Public Member Functions

void ClearHttpRequestOptions ()
 Clears the HTTP request options sent with every request, if any.
void Dispose ()
Luciad.Net.Http.HttpResponse Send (Luciad.Net.Http.HttpRequest request)
 Returns the HTTP response for the given HTTP request.
Luciad.Net.Http.HttpResponse Send (Luciad.Net.Http.HttpRequest request, Luciad.Concurrent.CancellationToken token)
 Returns the HTTP response for the given HTTP request.

Static Public Member Functions

static Luciad.Net.Http.HttpClient.Builder NewBuilder ()
 Creates the new HttpClient builder.

Properties

Luciad.Net.Http.HttpRequestOptions HttpRequestOptions [get, set]
 The HTTP request options sent with every request.

Detailed Description

An HTTP Client, implementation of the 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.

Example

HttpRequest request = HttpRequest.NewBuilder().Uri("https://foo.com/").Method(HttpRequestMethod.POST).Body(new DataEntity(buffer, "application/json")).Build();
HttpClient client = HttpClient.NewBuilder().ProxySelector(proxySelector).CredentialProvider(credentialsProvider).Build();
HttpResponse response = client.Send(request);
Console.WriteLine(response.StatusCode);

This class is thread-safe, i.e. it can handle multiple concurrent requests.

SSL

This HTTP client class performs, by default, SSL verification.

Windows
The system certificate authority (CA) file store is used.
Linux
The system certificate authority (CA) file store is used.
Android
The certificate authority (CA) file is shipped as a resource (resources/ssl/cacert.pem). It is a copy of the CA certificate extract from the cURL site.
Custom CA file
You can customize the used certificate authority (CA) file by calling HttpClient.Builder.CaCertFile.
Since
2023.0

Member Function Documentation

◆ ClearHttpRequestOptions()

void Luciad.Net.Http.HttpClient.ClearHttpRequestOptions ( )
inline

Clears the HTTP request options sent with every request, if any.

◆ Dispose()

void Luciad.Net.Http.HttpClient.Dispose ( )
inline

◆ NewBuilder()

Luciad.Net.Http.HttpClient.Builder Luciad.Net.Http.HttpClient.NewBuilder ( )
inlinestatic

Creates the new HttpClient builder.

Returns
the new HttpClient builder.

◆ Send() [1/2]

Luciad.Net.Http.HttpResponse Luciad.Net.Http.HttpClient.Send ( Luciad.Net.Http.HttpRequest request)
inline

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.

Parameters
requestHTTP request.
Returns
the HTTP response.
Exceptions
System.IO.IOExceptionwhen loading the data fails.

◆ Send() [2/2]

Luciad.Net.Http.HttpResponse Luciad.Net.Http.HttpClient.Send ( Luciad.Net.Http.HttpRequest request,
Luciad.Concurrent.CancellationToken token )
inline

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 an HTTP response is no longer needed.

Parameters
requestHTTP request.
tokenCancellation token.
Returns
the HTTP response.
Exceptions
System.IO.IOExceptionwhen loading the data fails.

Implements Luciad.Net.Http.IHttpClient.

Property Documentation

◆ HttpRequestOptions

Luciad.Net.Http.HttpRequestOptions Luciad.Net.Http.HttpClient.HttpRequestOptions
getset

The HTTP request options sent with every request.

[get]

Returns the HTTP request options sent with every request.

[set]

Sets the HTTP request options sent with every request.