Interface IHttpClient
Interface wrapper of HttpClient for testability. https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-guidelines#general-idisposable-guidelines
Namespace: Tableau.Migration.Net
Assembly: Tableau.Migration.dll
Syntax
public interface IHttpClient
Methods
SendAsync(HttpRequestMessage, HttpCompletionOption, CancellationToken)
Send an HTTP request as an asynchronous operation.
Declaration
Task<IHttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
HttpRequestMessage | request | The HTTP request message to send. |
HttpCompletionOption | completionOption | When the operation should complete (as soon as a response is available or after reading the whole response content). |
CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
Type | Description |
---|---|
Task<IHttpResponseMessage> | The task object representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The request is null. |
InvalidOperationException | The request message was already sent by the HttpClient instance. |
HttpRequestException | The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout. |
SendAsync(HttpRequestMessage, CancellationToken)
Send an HTTP request as an asynchronous operation.
Declaration
Task<IHttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
HttpRequestMessage | request | The HTTP request message to send. |
CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
Type | Description |
---|---|
Task<IHttpResponseMessage> | The task object representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The request is null. |
InvalidOperationException | The request message was already sent by the HttpClient instance. |
HttpRequestException | The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout. |
SendAsync<TResponse>(HttpRequestMessage, CancellationToken)
Send an HTTP request as an asynchronous operation.
Declaration
Task<IHttpResponseMessage<TResponse>> SendAsync<TResponse>(HttpRequestMessage request, CancellationToken cancellationToken) where TResponse : class
Parameters
Type | Name | Description |
---|---|---|
HttpRequestMessage | request | The HTTP request message to send. |
CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
Type | Description |
---|---|
Task<IHttpResponseMessage<TResponse>> | The task object representing the asynchronous operation. |
Type Parameters
Name | Description |
---|---|
TResponse |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The request is null. |
InvalidOperationException | The request message was already sent by the HttpClient instance. |
HttpRequestException | The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout. |