Table of Contents

Class UriExtensions

Namespace
Cuemon.Extensions.Net.Http
Assembly
Cuemon.Extensions.Net.dll

Extension methods for the System.Uri struct.

public static class UriExtensions
Inheritance
Object
UriExtensions

Properties

DefaultHttpClientFactory

Gets or sets the default System.Net.Http.IHttpClientFactory implementation for the extensions methods on this class.

public static IHttpClientFactory DefaultHttpClientFactory { get; set; }

Property Value

IHttpClientFactory

The default System.Net.Http.IHttpClientFactory implementation for the URI extensions methods on this class.

Methods

HttpAsync(Uri, Action<HttpRequestOptions>)

Send a request as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpAsync(this Uri location, Action<HttpRequestOptions> setup)

Parameters

location Uri

The System.Uri to extend.

setup Action<HttpRequestOptions>

The HttpRequestOptions which need to be configured.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpAsync(Uri, HttpMethod, MediaTypeHeaderValue, Stream, CancellationToken)

Send a request as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpAsync(this Uri location, HttpMethod method, MediaTypeHeaderValue contentType, Stream content, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

method HttpMethod

The HTTP method.

contentType MediaTypeHeaderValue

The Content-Type header of the HTTP request sent to the server.

content Stream

The HTTP request content sent to the server.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null -or- method cannot be null -or- contentType cannot be null -or- content cannot be null.

HttpAsync(Uri, HttpMethod, String, Stream, CancellationToken)

Send a request as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpAsync(this Uri location, HttpMethod method, string contentType, Stream content, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

method HttpMethod

The HTTP method.

contentType String

The Content-Type header of the HTTP request sent to the server.

content Stream

The HTTP request content sent to the server.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null -or- method cannot be null -or- contentType cannot be null -or- content cannot be null.

HttpDeleteAsync(Uri, CancellationToken)

Send a DELETE request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpDeleteAsync(this Uri location, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpGetAsync(Uri, CancellationToken)

Send a GET request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpGetAsync(this Uri location, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpHeadAsync(Uri, CancellationToken)

Send a HEAD request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpHeadAsync(this Uri location, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpOptionsAsync(Uri, CancellationToken)

Send an OPTIONS request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpOptionsAsync(this Uri location, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpPatchAsync(Uri, MediaTypeHeaderValue, Stream, CancellationToken)

Send a PATCH request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpPatchAsync(this Uri location, MediaTypeHeaderValue contentType, Stream content, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

contentType MediaTypeHeaderValue

The Content-Type header of the HTTP request sent to the server.

content Stream

The HTTP request content sent to the server.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpPatchAsync(Uri, String, Stream, CancellationToken)

Send a PATCH request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpPatchAsync(this Uri location, string contentType, Stream content, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

contentType String

The Content-Type header of the HTTP request sent to the server.

content Stream

The HTTP request content sent to the server.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpPostAsync(Uri, MediaTypeHeaderValue, Stream, CancellationToken)

Send a POST request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpPostAsync(this Uri location, MediaTypeHeaderValue contentType, Stream content, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

contentType MediaTypeHeaderValue

The Content-Type header of the HTTP request sent to the server.

content Stream

The HTTP request content sent to the server.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpPostAsync(Uri, String, Stream, CancellationToken)

Send a POST request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpPostAsync(this Uri location, string contentType, Stream content, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

contentType String

The Content-Type header of the HTTP request sent to the server.

content Stream

The HTTP request content sent to the server.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpPutAsync(Uri, MediaTypeHeaderValue, Stream, CancellationToken)

Send a PUT request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpPutAsync(this Uri location, MediaTypeHeaderValue contentType, Stream content, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

contentType MediaTypeHeaderValue

The Content-Type header of the HTTP request sent to the server.

content Stream

The HTTP request content sent to the server.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpPutAsync(Uri, String, Stream, CancellationToken)

Send a PUT request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpPutAsync(this Uri location, string contentType, Stream content, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

contentType String

The Content-Type header of the HTTP request sent to the server.

content Stream

The HTTP request content sent to the server.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.

HttpTraceAsync(Uri, CancellationToken)

Send a TRACE request to the specified Uri as an asynchronous operation.

public static async Task<HttpResponseMessage> HttpTraceAsync(this Uri location, CancellationToken ct = default(CancellationToken))

Parameters

location Uri

The System.Uri to extend.

ct CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

System.ArgumentNullException

location cannot be null.