Class HttpClientExtensions
Provides extension methods for HttpClient and related classes.
public static class HttpClientExtensions
- Inheritance
-
HttpClientExtensions
Methods
AsWebException(HttpRequestException)
Converts a HttpRequestException into a WebException.
public static WebException AsWebException(this HttpRequestException exception)
Parameters
exception
HttpRequestException
Returns
ReadAsStream(HttpContent, CancellationToken)
Reads the content as a stream.
public static Stream ReadAsStream(this HttpContent content, CancellationToken cancellationToken = default)
Parameters
content
HttpContentcancellationToken
CancellationToken
Returns
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
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
Exceptions
- HttpRequestException
The request failed due to a network, DNS or certificate issue.