Table of Contents

Class HttpClientExtensions

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

Provides extension methods for the HttpClient class.

public static class HttpClientExtensions
Inheritance
HttpClientExtensions

Methods

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

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

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

Parameters

client HttpClient

The HttpClient to extend.

responseFactory Func<HttpClient, Task<HttpResponseMessage>>

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

Returns

Task<HttpResponseMessage>

A Task that represents the asynchronous operation. The task result contains the HttpResponseMessage generated by the responseFactory.

Remarks

Exceptions

ArgumentNullException

client cannot be null.