Class DotNetHttpClient
An implementation of IHttpClient for .Net specific applications
Inherited Members
Namespace: Unity.Cloud.Common
Assembly: Unity.Cloud.Common.dll
Syntax
public class DotNetHttpClient : IHttpClient, IDisposable
Constructors
DotNetHttpClient()
Initializes and returns an instance of DotNetHttpClient.
Declaration
public DotNetHttpClient()
Properties
Timeout
The timespan to wait before the request times out.
Declaration
public TimeSpan Timeout { get; set; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
Methods
Dispose()
Ensure disposal of any IDisposable references.
Declaration
public void Dispose()
Dispose(bool)
Ensure internal disposal of any IDisposable references.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | Dispose pattern boolean value received from public Dispose method. |
SendAsync(HttpRequestMessage, HttpCompletionOption, IProgress<HttpProgress>, CancellationToken)
Sends an asynchronous HTTP request.
Declaration
public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, IProgress<HttpProgress> progress, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpRequestMessage | request | The request to be sent. |
| HttpCompletionOption | completionOption | When the operation should complete. |
| IProgress<HttpProgress> | progress | The progress provider. |
| CancellationToken | cancellationToken | Cancellation token that will try to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<HttpResponseMessage> | A task that will hold the HttpResponseMessage once the request is completed |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when the request is null. |
| HttpRequestException | Thrown when an HTTP response can't be obtained from the server. |
| OperationCanceledException | Thrown when the request is cancelled by a cancellation token or due to timeout. |