Class HttpMessageHandlerBuilder
The class that builds a HttpMessageHandler instance.
public sealed class HttpMessageHandlerBuilder
- Inheritance
-
HttpMessageHandlerBuilder
- Inherited Members
Constructors
HttpMessageHandlerBuilder()
public HttpMessageHandlerBuilder()
Methods
Build()
Builds new instance of HttpMessageHandler.
public HttpMessageHandler Build()
Returns
UseAllowAutoRedirect(in bool)
Sets the AllowAutoRedirect value.
public HttpMessageHandlerBuilder UseAllowAutoRedirect(in bool value)
Parameters
valueboolThe AllowAutoRedirect value.
Returns
UseAutomaticDecompression(in DecompressionMethods)
Sets the AutomaticDecompression value to DecompressionMethods.All.
public HttpMessageHandlerBuilder UseAutomaticDecompression(in DecompressionMethods value)
Parameters
valueDecompressionMethodsThe DecompressionMethods value.
Returns
UseCheckCertificateRevocationList(in bool)
Sets the CheckCertificateRevocationList value.
public HttpMessageHandlerBuilder UseCheckCertificateRevocationList(in bool value)
Parameters
valueboolThe CheckCertificateRevocationList value.
Returns
UseClientCertificate(X509Certificate2)
Adds the X509Certificate2 value.
public HttpMessageHandlerBuilder UseClientCertificate(X509Certificate2 value)
Parameters
valueX509Certificate2The X509Certificate2 value.
Returns
Remarks
This certificate is ignored when a certificate callback is provided by UseClientCertificateCallback(Func<X509Certificate2>).
UseClientCertificateCallback(Func<X509Certificate2>)
Configures the client certificate callback using the specified Func<TResult> for X509Certificate2. This method allows deferred assignment of the client certificate through a callback function.
public HttpMessageHandlerBuilder UseClientCertificateCallback(Func<X509Certificate2> value)
Parameters
valueFunc<X509Certificate2>The callback function that provides the X509Certificate2 value.
Returns
- HttpMessageHandlerBuilder
The current HttpMessageHandlerBuilder instance, enabling method chaining.
Remarks
This certificate returned by the callback will supersede the one provided . UseClientCertificate(X509Certificate2) The callback will be executed for every HTTP request, unless the connection is reused, in which case the previously provided certificate will be used.
UseConnectTimeout(in TimeSpan)
Sets the connect timeout.
public HttpMessageHandlerBuilder UseConnectTimeout(in TimeSpan value)
Parameters
Returns
UseCookies(in bool)
Sets the UseCookies value.
public HttpMessageHandlerBuilder UseCookies(in bool value)
Parameters
valueboolThe UseCookies value.
Returns
UseCredentials(in NetworkCredential)
Sets the Credentials value.
public HttpMessageHandlerBuilder UseCredentials(in NetworkCredential value)
Parameters
valueNetworkCredentialThe Credentials value.
Returns
UseEnableMultipleHttp2Connections(in bool)
Sets a flag on the SocketsHttpHandler - based HttpMessageHandler that allows multiple HTTP2 connections to be established if all the streams in one are in use. Should be combined with UsePooledConnectionLifetime(in TimeSpan) to prune any extra connections.
public HttpMessageHandlerBuilder UseEnableMultipleHttp2Connections(in bool value)
Parameters
valueboolA boolean indicating if additional http2 connections should be allowed.
Returns
UseMaxConnectionsPerServer(in int)
Sets the MaxConnectionsPerServer value.
public HttpMessageHandlerBuilder UseMaxConnectionsPerServer(in int value)
Parameters
valueintThe MaxConnectionsPerServer value.
Returns
UsePooledConnectionLifetime(in TimeSpan)
Sets the pooled connection lifetime of the SocketsHttpHandler - based HttpMessageHandler.
public HttpMessageHandlerBuilder UsePooledConnectionLifetime(in TimeSpan value)
Parameters
valueTimeSpanThe pooled connection lifetime value.
Returns
UseProxy(in bool)
Sets the UseProxy value.
public HttpMessageHandlerBuilder UseProxy(in bool value)
Parameters
Returns
UseServerCertificateCustomValidationCallback(Func<object, X509Certificate2?, X509Chain?, SslPolicyErrors, bool>)
Sets the ServerCertificateCustomValidationCallback value.
public HttpMessageHandlerBuilder UseServerCertificateCustomValidationCallback(Func<object, X509Certificate2?, X509Chain?, SslPolicyErrors, bool> value)
Parameters
valueFunc<object, X509Certificate2, X509Chain, SslPolicyErrors, bool>The ServerCertificateCustomValidationCallback value.