Table of Contents

Class HttpClientExtensions

Namespace
Codebelt.Extensions.Xunit.Hosting.AspNetCore
Assembly
Codebelt.Extensions.Xunit.Hosting.AspNetCore.dll

Provides extension methods for the System.Net.Http.HttpClient class.

public static class HttpClientExtensions
Inheritance
Object
HttpClientExtensions

Methods

ToHttpResponseMessageAsync(HttpClient, Func<HttpClient, Task<HttpResponseMessage>>)

Provides a convenient way to return a System.Net.Http.HttpResponseMessage from a System.Net.Http.HttpClient using the specified responseFactory.

public static async Task<HttpResponseMessage> ToHttpResponseMessageAsync(this HttpClient client, Func<HttpClient, Task<HttpResponseMessage>> responseFactory = null)

Parameters

client HttpClient

The System.Net.Http.HttpClient to extend.

responseFactory Func<HttpClient, Task<HttpResponseMessage>>

The function delegate that creates a System.Net.Http.HttpResponseMessage from the System.Net.Http.HttpClient. Default is a GET request to the root URL ("/").

Returns

Task<HttpResponseMessage>

A System.Threading.Tasks.Task that represents the asynchronous operation. The task result contains the System.Net.Http.HttpResponseMessage generated by the responseFactory.

Remarks

Exceptions

System.ArgumentNullException

client cannot be null.