Table of Contents

Class HttpClientExtensions

Namespace
NanoByte.Common.Net
Assembly
NanoByte.Common.dll

Provides extension methods for HttpClient and related classes.

public static class HttpClientExtensions
Inheritance
HttpClientExtensions

Methods

AsWebException(HttpRequestException)

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 HttpContent
cancellationToken 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 HttpClient
request HttpRequestMessage
completionOption HttpCompletionOption
cancellationToken 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 HttpClient
request HttpRequestMessage
cancellationToken CancellationToken

Returns

HttpResponseMessage

Exceptions

HttpRequestException

The request failed due to a network, DNS or certificate issue.