Condividi tramite


HttpClientBuilderExtensions Class

Definition

Extension methods for configuring an IHttpClientBuilder.

public ref class HttpClientBuilderExtensions abstract sealed
public static class HttpClientBuilderExtensions
type HttpClientBuilderExtensions = class
Public Module HttpClientBuilderExtensions
Inheritance
HttpClientBuilderExtensions

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

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

AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,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,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.

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, Func<HttpClient,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.

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

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

ConfigureHttpClient(IHttpClientBuilder, Action<IServiceProvider,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<HttpMessageHandler>)

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<THandler>(IHttpClientBuilder)

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

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.

RedactLoggedHeaders(IHttpClientBuilder, IEnumerable<String>)

Sets the collection of HTTP headers names for which values should be redacted 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.

Applies to