Compartilhar via


IHttpClientBuilder Interface

Definition

A builder for configuring named HttpClient instances returned by IHttpClientFactory.

public interface class IHttpClientBuilder
public interface IHttpClientBuilder
type IHttpClientBuilder = interface
Public Interface IHttpClientBuilder

Properties

Name

Gets the name of the client configured by this builder.

Services

Gets the application service collection.

Extension Methods

AddAsKeyed(IHttpClientBuilder, ServiceLifetime)

Registers a named HttpClient and the related handler pipeline HttpMessageHandler as keyed services with the client's name as the key, and a lifetime provided in the lifetime parameter. By default, the lifetime is Scoped.

AddDefaultLogger(IHttpClientBuilder)

Adds back the default logging for a named HttpClient, if it was removed previously by calling RemoveAllLoggers(IHttpClientBuilder).

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>)

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

AddHttpMessageHandler<THandler>(IHttpClientBuilder)

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

AddLogger(IHttpClientBuilder, Func<IServiceProvider,IHttpClientLogger>, Boolean)

Adds a delegate that will be used to create an additional logger for a named HttpClient. The custom logger would be invoked from a dedicated logging DelegatingHandler on every request of the corresponding named HttpClient.

AddLogger<TLogger>(IHttpClientBuilder, Boolean)

Adds a delegate that will be used to create an additional logger for a named HttpClient. The custom logger would be invoked from a dedicated logging DelegatingHandler on every request of the corresponding named HttpClient.

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>)

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

AddTypedClient<TClient>(IHttpClientBuilder)

Configures a binding between the TClient type and the named HttpClient associated with the 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.

ConfigureAdditionalHttpMessageHandlers(IHttpClientBuilder, Action<IList<DelegatingHandler>,IServiceProvider>)

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

ConfigureHttpClient(IHttpClientBuilder, Action<IServiceProvider,HttpClient>)

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

ConfigureHttpClient(IHttpClientBuilder, Action<HttpClient>)

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

ConfigureHttpMessageHandlerBuilder(IHttpClientBuilder, Action<HttpMessageHandlerBuilder>)
Obsolete.

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

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Action<HttpMessageHandler,IServiceProvider>)

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

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>)

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

ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder)

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

RedactLoggedHeaders(IHttpClientBuilder, IEnumerable<String>)

Sets the collection of HTTP headers names for which values should be redacted before logging.

RedactLoggedHeaders(IHttpClientBuilder, Func<String,Boolean>)

Sets the Func<T,TResult> which determines whether to redact the HTTP header value given its corresponding header name before logging.

RemoveAllLoggers(IHttpClientBuilder)

Removes all previously added loggers for a named HttpClient, including default ones.

RemoveAsKeyed(IHttpClientBuilder)

Removes the keyed registrations for the named HttpClient and HttpMessageHandler.

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.

UseSocketsHttpHandler(IHttpClientBuilder, Action<ISocketsHttpHandlerBuilder>)

Adds or updates SocketsHttpHandler as a primary handler for a named HttpClient and configures it using ISocketsHttpHandlerBuilder.

UseSocketsHttpHandler(IHttpClientBuilder, Action<SocketsHttpHandler,IServiceProvider>)

Adds or updates SocketsHttpHandler as a primary handler for a named HttpClient. If provided, also adds a delegate that will be used to configure the primary SocketsHttpHandler.

AddExtendedHttpClientLogging(IHttpClientBuilder, IConfigurationSection)

Adds an IHttpClientAsyncLogger to emit logs for outgoing requests for a named HttpClient.

AddExtendedHttpClientLogging(IHttpClientBuilder, Action<LoggingOptions>)

Adds an IHttpClientAsyncLogger to emit logs for outgoing requests for a named HttpClient.

AddExtendedHttpClientLogging(IHttpClientBuilder)

Adds an IHttpClientAsyncLogger to emit logs for outgoing requests for a named HttpClient.

AddPolicyHandler(IHttpClientBuilder, IAsyncPolicy<HttpResponseMessage>)

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

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<IServiceProvider,HttpRequestMessage, String,IAsyncPolicy<HttpResponseMessage>>, Func<HttpRequestMessage, String>)

Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by executing provided key selection logic keySelector and policyFactory.

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>>)

Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the IReadOnlyPolicyRegistry<TKey>.

AddPolicyHandlerFromRegistry(IHttpClientBuilder, String)

Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the IReadOnlyPolicyRegistry<TKey>.

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

Adds a PolicyHttpMessageHandler which will surround request execution with a 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.

AddResilienceHandler(IHttpClientBuilder, String, Action<ResiliencePipelineBuilder<HttpResponseMessage>,ResilienceHandlerContext>)

Adds a resilience pipeline handler that uses a named inline resilience pipeline.

AddResilienceHandler(IHttpClientBuilder, String, Action<ResiliencePipelineBuilder<HttpResponseMessage>>)

Adds a resilience pipeline handler that uses a named inline resilience pipeline.

AddStandardHedgingHandler(IHttpClientBuilder, Action<IRoutingStrategyBuilder>)

Adds a standard hedging handler that wraps the execution of the request with a standard hedging mechanism.

AddStandardHedgingHandler(IHttpClientBuilder)

Adds a standard hedging handler that wraps the execution of the request with a standard hedging mechanism.

AddStandardResilienceHandler(IHttpClientBuilder, IConfigurationSection)

Adds a standard resilience handler that uses multiple resilience strategies with default options to send the requests and handle any transient errors.

AddStandardResilienceHandler(IHttpClientBuilder, Action<HttpStandardResilienceOptions>)

Adds a standard resilience handler that uses multiple resilience strategies with default options to send the requests and handle any transient errors.

AddStandardResilienceHandler(IHttpClientBuilder)

Adds a standard resilience handler that uses multiple resilience strategies with default options to send the requests and handle any transient errors.

Applies to