Class HttpClientExtensions
Provides extension methods for System.Net.Http.HttpClient and related classes.
public static class HttpClientExtensions
- Inheritance
-
objectHttpClientExtensions
Methods
AsWebException(HttpRequestException)
Converts a System.Net.Http.HttpRequestException into a System.Net.WebException.
public static WebException AsWebException(this HttpRequestException exception)
Parameters
exception
HttpRequestException
Returns
- WebException
ReadAsStream(HttpContent, CancellationToken)
Reads the content as a stream.
public static Stream ReadAsStream(this HttpContent content, CancellationToken cancellationToken = default)
Parameters
content
HttpContentcancellationToken
CancellationToken
Returns
- Stream
Send(HttpClient, HttpRequestMessage, HttpCompletionOption, CancellationToken)
Sends an HTTP request and waits for the result is synchronously.
public static HttpResponseMessage Send(this HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken = default)
Parameters
client
HttpClientrequest
HttpRequestMessagecompletionOption
HttpCompletionOptioncancellationToken
CancellationToken
Returns
- HttpResponseMessage
Exceptions
- HttpRequestException
The request failed due to a network, DNS or certificate issue.
Send(HttpClient, HttpRequestMessage, CancellationToken)
Sends an HTTP request and waits for the result is synchronously.
public static HttpResponseMessage Send(this HttpClient client, HttpRequestMessage request, CancellationToken cancellationToken = default)
Parameters
client
HttpClientrequest
HttpRequestMessagecancellationToken
CancellationToken
Returns
- HttpResponseMessage
Exceptions
- HttpRequestException
The request failed due to a network, DNS or certificate issue.