Interface IHttpClient
Interface that represent a client for making http requests.
Namespace: Unity.Cloud.Common
Syntax
public interface IHttpClientProperties
Timeout
The timespan to wait before the request times out.
Declaration
TimeSpan Timeout { get; set; }Property Value
| Type | Description | 
|---|---|
| TimeSpan | 
Methods
DownloadFileAsync(HttpRequestMessage, String, CancellationToken)
Send an asynchronous file download request.
Declaration
Task<HttpResponseMessage> DownloadFileAsync(HttpRequestMessage request, string downloadFilePath, CancellationToken cancellationToken = default(CancellationToken))Parameters
| Type | Name | Description | 
|---|---|---|
| HttpRequestMessage | request | The request to be sent. | 
| String | downloadFilePath | Optional path to save downloaded files. | 
| CancellationToken | cancellationToken | Optional 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 | 
SendAsync(HttpRequestMessage, CancellationToken)
Send an asynchronous HTTP request.
Declaration
Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default(CancellationToken))Parameters
| Type | Name | Description | 
|---|---|---|
| HttpRequestMessage | request | The request to be sent. | 
| CancellationToken | cancellationToken | Optional 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. | 
| TimeoutException | Thrown when the request failed due to timeout. |