Table of Contents

Class WebApplicationHttpClientFactory

Namespace
Xping.Sdk.Core.Clients.Http
Assembly
Xping.Sdk.Core.dll

Custom implementation of IHttpClientFactory specifically designed for use with WebApplicationFactory. The purpose of this class is to ensure that the pre-configured HttpClient instance created by the WebApplicationFactory.CreateClient method is returned, which aligns with additional system requirements where HttpClient objects are constructed via IHttpClientFactory.

public class WebApplicationHttpClientFactory : IHttpClientFactory
Inheritance
WebApplicationHttpClientFactory
Implements
Inherited Members

Constructors

WebApplicationHttpClientFactory(Func<WebApplicationFactoryClientOptions, HttpClient>, HttpClientFactoryConfiguration)

Custom implementation of IHttpClientFactory specifically designed for use with WebApplicationFactory. The purpose of this class is to ensure that the pre-configured HttpClient instance created by the WebApplicationFactory.CreateClient method is returned, which aligns with additional system requirements where HttpClient objects are constructed via IHttpClientFactory.

public WebApplicationHttpClientFactory(Func<WebApplicationFactoryClientOptions, HttpClient> createClient, HttpClientFactoryConfiguration factoryConfiguration)

Parameters

createClient Func<WebApplicationFactoryClientOptions, HttpClient>
factoryConfiguration HttpClientFactoryConfiguration

Methods

CreateClient(string)

Returns the HttpClient instance that was provided during the factory's instantiation.

public HttpClient CreateClient(string name)

Parameters

name string

The logical name of the client to create. This parameter is not used in this implementation but is required by the interface.

Returns

HttpClient

The pre-configured HttpClient instance.

CreateWebApplicationFactoryClientOptions()

Creates and configures an instance of WebApplicationFactoryClientOptions.

protected virtual WebApplicationFactoryClientOptions CreateWebApplicationFactoryClientOptions()

Returns

WebApplicationFactoryClientOptions

A WebApplicationFactoryClientOptions object configured with: AllowAutoRedirect set to false, HandleCookies set to false, and MaxAutomaticRedirections set to 0.

Remarks

This method provides a WebApplicationFactoryClientOptions object with predefined settings. The settings disable automatic redirections and cookie handling for the HTTP client used by the WebApplicationFactory. This is useful when you need to test the behavior of endpoints that perform redirections or set cookies without following them automatically.