Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Microsoft.​Extensions.​Http.​HttpClientFactoryOptions

Assembly: Microsoft.Extensions.Http

Inheritance: object → HttpClientFactoryOptions

Provides options for configuring the default <see cref="T:System.Net.Http.IHttpClientFactory" /> .

Properties

HandlerLifetime
Gets or sets the length of time that a <see cref="T:System.Net.Http.HttpMessageHandler" /> instance can be reused. Each named client can have its own configured handler lifetime value. The default value of this property is two minutes. Set the lifetime to <see cref="F:System.Threading.Timeout.InfiniteTimeSpan" /> to disable handler expiry.
Remarks <para> The default implementation of <see cref="T:System.Net.Http.IHttpClientFactory" /> will pool the <see cref="T:System.Net.Http.HttpMessageHandler" /> instances created by the factory to reduce resource consumption. This setting configures the amount of time a handler can be pooled before it is scheduled for removal from the pool and disposal. </para> <para> Pooling of handlers is desirable as each handler typically manages its own underlying HTTP connections; creating more handlers than necessary can result in connection delays. Some handlers also keep connections open indefinitely which can prevent the handler from reacting to DNS changes. The value of <see cref="P:Microsoft.Extensions.Http.HttpClientFactoryOptions.HandlerLifetime" /> should be chosen with an understanding of the application's requirement to respond to changes in the network environment. </para> <para> Expiry of a handler will not immediately dispose the handler. An expired handler is placed in a separate pool which is processed at intervals to dispose handlers only when they become unreachable. Using long-lived <see cref="T:System.Net.Http.HttpClient" /> instances will prevent the underlying <see cref="T:System.Net.Http.HttpMessageHandler" /> from being disposed until all references are garbage-collected. </para>
Gets a list of operations used to configure an <see cref="T:System.Net.Http.HttpClient" /> .
Gets a list of operations used to configure an <see cref="T:Microsoft.Extensions.Http.HttpMessageHandlerBuilder" /> .
public System.​Func<​string, bool>
ShouldRedactHeaderValue
Gets or sets the <see cref="T:System.Func`2" /> that determines whether to redact the HTTP header value before logging.
public bool
SuppressHandlerScope
<para> Gets or sets a value that determines whether the <see cref="T:System.Net.Http.IHttpClientFactory" /> will create a dependency injection scope when building an <see cref="T:System.Net.Http.HttpMessageHandler" />. If <c>false</c> (default), a scope will be created, otherwise a scope will not be created. </para> <para> This option is provided for compatibility with existing applications. It is recommended to use the default setting for new applications. </para>
Remarks <para> The <see cref="T:System.Net.Http.IHttpClientFactory" /> will (by default) create a dependency injection scope each time it creates an <see cref="T:System.Net.Http.HttpMessageHandler" />. The created scope has the same lifetime as the message handler, and will be disposed when the message handler is disposed. </para> <para> When operations that are part of <see cref="P:Microsoft.Extensions.Http.HttpClientFactoryOptions.HttpMessageHandlerBuilderActions" /> are executed they will be provided with the scoped <see cref="T:System.IServiceProvider" /> via <see cref="P:Microsoft.Extensions.Http.HttpMessageHandlerBuilder.Services" />. This includes retrieving a message handler from dependency injection, such as one registered using <see cref="M:Microsoft.Extensions.DependencyInjection.HttpClientBuilderExtensions.AddHttpMessageHandler``1(Microsoft.Extensions.DependencyInjection.IHttpClientBuilder)" />. </para>

Methods

public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object