IHttpClientBuilder 介面

定義

用來設定 IHttpClientFactory 所傳回具名 HttpClient 執行個體的建立器。A builder for configuring named HttpClient instances returned by IHttpClientFactory.

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

屬性

Name

取得此建立器所設定的用戶端名稱。Gets the name of the client configured by this builder.

Services

取得應用程式服務集合。Gets the application service collection.

擴充方法

AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>)

新增將用於為具名 HttpClient 建立其他訊息處理常式的委派。Adds a delegate that will be used to create an additional message handler for a named HttpClient.

AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>)

新增將用於為具名 HttpClient 建立其他訊息處理常式的委派。Adds a delegate that will be used to create an additional message handler for a named HttpClient.

AddHttpMessageHandler<THandler>(IHttpClientBuilder)

從具名 HttpClient 的相依性插入容器中,新增額外的訊息處理常式。Adds an additional message handler from the dependency injection container for a named HttpClient.

AddTypedClient<TClient>(IHttpClientBuilder)

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。Configures a binding between the TClient type and the named HttpClient associated with the IHttpClientBuilder.

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

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。Configures a binding between the TClient type and the named HttpClient associated with the IHttpClientBuilder.

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

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。Configures a binding between the TClient type and the named HttpClient associated with the IHttpClientBuilder.

AddTypedClient<TClient,TImplementation>(IHttpClientBuilder)

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。Configures a binding between the TClient type and the named HttpClient associated with the IHttpClientBuilder. 建立的執行個體將屬於類型 TImplementationThe created instances will be of type TImplementation.

ConfigureHttpClient(IHttpClientBuilder, Action<IServiceProvider,HttpClient>)

新增將用於設定具名 HttpClient 的委派。Adds a delegate that will be used to configure a named HttpClient.

ConfigureHttpClient(IHttpClientBuilder, Action<HttpClient>)

新增將用於設定具名 HttpClient 的委派。Adds a delegate that will be used to configure a named HttpClient.

ConfigureHttpMessageHandlerBuilder(IHttpClientBuilder, Action<HttpMessageHandlerBuilder>)

新增用於設定訊息處理常式的委派,其會針對具名 HttpClient 使用 HttpMessageHandlerBuilderAdds a delegate that will be used to configure message handlers using HttpMessageHandlerBuilder for a named HttpClient.

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,HttpMessageHandler>)

新增將用來設定具名 HttpClient 之主要 HttpMessageHandler 的委派。Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>)

新增將用來設定具名 HttpClient 之主要 HttpMessageHandler 的委派。Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder)

從具名 HttpClient 的相依性插入容器中設定主要 HttpMessageHandlerConfigures the primary HttpMessageHandler from the dependency injection container for a named HttpClient.

RedactLoggedHeaders(IHttpClientBuilder, IEnumerable<String>)

設定應在記錄前修訂其值的 HTTP 標頭名稱集合。Sets the collection of HTTP header names for which values should be redacted before logging.

RedactLoggedHeaders(IHttpClientBuilder, Func<String,Boolean>)

設定 Func<T,TResult>,其可決定是否在記錄前先修訂 HTTP 標頭值。Sets the Func<T,TResult> which determines whether to redact the HTTP header value before logging.

SetHandlerLifetime(IHttpClientBuilder, TimeSpan)

設定可以重複使用 HttpMessageHandler 執行個體的時間長度。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. 將存留期設定成 InfiniteTimeSpan 以停用處理常式到期時間。Set the lifetime to InfiniteTimeSpan to disable handler expiry.

AddPolicyHandler(IHttpClientBuilder, IAsyncPolicy<HttpResponseMessage>)

新增 PolicyHttpMessageHandler,其會將提供的 IAsyncPolicy`1 以要求執行括住。Adds a PolicyHttpMessageHandler which will surround request execution with the provided IAsyncPolicy`1.

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

新增會以 policySelector 所傳回原則括住要求執行的 PolicyHttpMessageHandlerAdds 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>)

新增 PolicyHttpMessageHandler,其會以由執行所提供索引鍵選取項目邏輯 keySelectorpolicyFactory 傳回的策略來括住要求執行。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>>)

新增會以 policySelector 所傳回原則括住要求執行的 PolicyHttpMessageHandlerAdds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the policySelector.

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

新增會以 IReadOnlyPolicyRegistry<TKey> 所傳回原則括住要求執行的 PolicyHttpMessageHandlerAdds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the IReadOnlyPolicyRegistry<TKey>.

AddPolicyHandlerFromRegistry(IHttpClientBuilder, String)

新增會以 IReadOnlyPolicyRegistry<TKey> 所傳回原則括住要求執行的 PolicyHttpMessageHandlerAdds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the IReadOnlyPolicyRegistry<TKey>.

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

新增 PolicyHttpMessageHandler,其會以執行所提供組態委派建立的 Policy 來括住要求執行。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.

適用於