IHttpClientBuilder IHttpClientBuilder IHttpClientBuilder Interface

Definition

A builder for configuring named HttpClient instances returned by IHttpClientFactory.

public interface IHttpClientBuilder
type IHttpClientBuilder = interface
Public Interface IHttpClientBuilder

Properties

Name Name Name

Gets the name of the client configured by this builder.

Services Services Services

Gets the application service collection.

Extension Methods

AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>) AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>) AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>)

Adds a delegate that will be used to create an additional message handler for a named HttpClient.

AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>) AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>) AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>)

Adds a delegate that will be used to create an additional message handler for a named HttpClient.

AddHttpMessageHandler<THandler>(IHttpClientBuilder) AddHttpMessageHandler<THandler>(IHttpClientBuilder) AddHttpMessageHandler<THandler>(IHttpClientBuilder)

Adds an additional message handler from the dependency injection container for a named HttpClient.

AddTypedClient<TClient>(IHttpClientBuilder) AddTypedClient<TClient>(IHttpClientBuilder) AddTypedClient<TClient>(IHttpClientBuilder)

Configures a binding between the TClient type and the named HttpClient associated with the IHttpClientBuilder.

AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>) AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>) AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>)

Configures a binding between the TClient type and the named HttpClient associated with the IHttpClientBuilder.

AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>) AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>) AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>)

Configures a binding between the TClient type and the named HttpClient associated with the IHttpClientBuilder.

AddTypedClient<TClient,TImplementation>(IHttpClientBuilder) AddTypedClient<TClient,TImplementation>(IHttpClientBuilder) AddTypedClient<TClient,TImplementation>(IHttpClientBuilder)

Configures a binding between the TClient type and the named HttpClient associated with the IHttpClientBuilder. The created instances will be of type TImplementation.

ConfigureHttpClient(IHttpClientBuilder, Action<IServiceProvider,HttpClient>) ConfigureHttpClient(IHttpClientBuilder, Action<IServiceProvider,HttpClient>) ConfigureHttpClient(IHttpClientBuilder, Action<IServiceProvider,HttpClient>)

Adds a delegate that will be used to configure a named HttpClient.

ConfigureHttpClient(IHttpClientBuilder, Action<HttpClient>) ConfigureHttpClient(IHttpClientBuilder, Action<HttpClient>) ConfigureHttpClient(IHttpClientBuilder, Action<HttpClient>)

Adds a delegate that will be used to configure a named HttpClient.

ConfigureHttpMessageHandlerBuilder(IHttpClientBuilder, Action<HttpMessageHandlerBuilder>) ConfigureHttpMessageHandlerBuilder(IHttpClientBuilder, Action<HttpMessageHandlerBuilder>) ConfigureHttpMessageHandlerBuilder(IHttpClientBuilder, Action<HttpMessageHandlerBuilder>)

Adds a delegate that will be used to configure message handlers using HttpMessageHandlerBuilder for a named HttpClient.

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,HttpMessageHandler>) ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,HttpMessageHandler>) ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,HttpMessageHandler>)

Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>) ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>) ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>)

Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder) ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder) ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder)

Configures the primary HttpMessageHandler from the dependency injection container for a named HttpClient.

SetHandlerLifetime(IHttpClientBuilder, TimeSpan) SetHandlerLifetime(IHttpClientBuilder, TimeSpan) SetHandlerLifetime(IHttpClientBuilder, TimeSpan)

Sets the length of time that a HttpMessageHandler instance can be reused. Each named client can have its own configured handler lifetime value. The default value is two minutes. Set the lifetime to InfiniteTimeSpan to disable handler expiry.

AddPolicyHandler(IHttpClientBuilder, IAsyncPolicy<HttpResponseMessage>) AddPolicyHandler(IHttpClientBuilder, IAsyncPolicy<HttpResponseMessage>) AddPolicyHandler(IHttpClientBuilder, IAsyncPolicy<HttpResponseMessage>)

Adds a PolicyHttpMessageHandler which will surround request execution with the provided Polly.IAsyncPolicy.

AddPolicyHandler(IHttpClientBuilder, Func<IServiceProvider,HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>) AddPolicyHandler(IHttpClientBuilder, Func<IServiceProvider,HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>) AddPolicyHandler(IHttpClientBuilder, Func<IServiceProvider,HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>)

Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the policySelector.

AddPolicyHandler(IHttpClientBuilder, Func<HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>) AddPolicyHandler(IHttpClientBuilder, Func<HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>) AddPolicyHandler(IHttpClientBuilder, Func<HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>)

Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the policySelector.

AddPolicyHandlerFromRegistry(IHttpClientBuilder, Func<IReadOnlyPolicyRegistry<String>,HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>) AddPolicyHandlerFromRegistry(IHttpClientBuilder, Func<IReadOnlyPolicyRegistry<String>,HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>) AddPolicyHandlerFromRegistry(IHttpClientBuilder, Func<IReadOnlyPolicyRegistry<String>,HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>)

Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the Polly.Registry.IReadOnlyPolicyRegistry.

AddPolicyHandlerFromRegistry(IHttpClientBuilder, String) AddPolicyHandlerFromRegistry(IHttpClientBuilder, String) AddPolicyHandlerFromRegistry(IHttpClientBuilder, String)

Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the Polly.Registry.IReadOnlyPolicyRegistry.

AddTransientHttpErrorPolicy(IHttpClientBuilder, Func<PolicyBuilder<HttpResponseMessage>,IAsyncPolicy<HttpResponseMessage>>) AddTransientHttpErrorPolicy(IHttpClientBuilder, Func<PolicyBuilder<HttpResponseMessage>,IAsyncPolicy<HttpResponseMessage>>) AddTransientHttpErrorPolicy(IHttpClientBuilder, Func<PolicyBuilder<HttpResponseMessage>,IAsyncPolicy<HttpResponseMessage>>)

Adds a PolicyHttpMessageHandler which will surround request execution with a Polly.Policy created by executing the provided configuration delegate. The policy builder will be preconfigured to trigger application of the policy for requests that fail with conditions that indicate a transient failure.

Applies to