Class HttpClientFromMessageHandlerFactory (1.50.0)

public sealed class HttpClientFromMessageHandlerFactory : object, IHttpClientFactory

An implementation of IHttpClientFactory that allows for the inner message handler to be injected.

Inheritance

Object > HttpClientFromMessageHandlerFactory

Implements

IHttpClientFactory

Namespace

Google.Apis.Http

Assembly

Google.Apis.Core.dll

Constructors

HttpClientFromMessageHandlerFactory(Func<HttpClientFromMessageHandlerFactory.HttpMessageHandlerOptions, HttpClientFromMessageHandlerFactory.ConfiguredHttpMessageHandler>)

public HttpClientFromMessageHandlerFactory(Func<HttpClientFromMessageHandlerFactory.HttpMessageHandlerOptions, HttpClientFromMessageHandlerFactory.ConfiguredHttpMessageHandler> httpMessageHandlerFactory)

Creates an HttpClientFromMessageHandlerFactory that will use the given factory for creating the inner message handlers that will be used when creating the ConfigurableHttpClient.

Parameter
NameDescription
httpMessageHandlerFactoryFunc<HttpClientFromMessageHandlerFactory.HttpMessageHandlerOptions, HttpClientFromMessageHandlerFactory.ConfiguredHttpMessageHandler>
Remarks

The obtained from the factory won't be disposed when the created ConfigurableHttpClient is. This allows calling code to control the handlers' lifetime and so they can possibly be reused. This may be a requirement for using System.Net.Http.IHttpMessageHandler. See https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests for information on why to use System.Net.Http.IHttpMessageHandler.

Methods

CreateHttpClient(CreateHttpClientArgs)

public ConfigurableHttpClient CreateHttpClient(CreateHttpClientArgs args)

Creates a new configurable HTTP client.

Parameter
NameDescription
argsCreateHttpClientArgs
Returns
TypeDescription
ConfigurableHttpClient

Extension Method