LaunchDarkly Dotnet Server SDK
Search Results for

    Show / Hide Table of Contents

    Class HttpConfigurationBuilder

    Contains methods for configuring the SDK's networking behavior.

    Inheritance
    object
    HttpConfigurationBuilder
    Implements
    IComponentConfigurer<HttpConfiguration>
    IDiagnosticDescription
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: LaunchDarkly.Sdk.Server.Integrations
    Assembly: LaunchDarkly.ServerSdk.dll
    Syntax
    public sealed class HttpConfigurationBuilder : IComponentConfigurer<HttpConfiguration>, IDiagnosticDescription
    Remarks

    If you want to set non-default values for any of these properties, create a builder with HttpConfiguration(), change its properties with the methods of this class, and pass it to Http(IComponentConfigurer<HttpConfiguration>):

    var config = Configuration.Builder(sdkKey)
          .Http(
              Components.HttpConfiguration()
                  .ConnectTimeout(TimeSpan.FromMilliseconds(3000))
          )
          .Build();

    Constructors

    View Source

    HttpConfigurationBuilder()

    Declaration
    public HttpConfigurationBuilder()

    Fields

    | Edit this page View Source

    DefaultConnectTimeout

    The default value for ConnectTimeout(TimeSpan): two seconds.

    Declaration
    public static readonly TimeSpan DefaultConnectTimeout
    Field Value
    Type Description
    TimeSpan
    | Edit this page View Source

    DefaultReadTimeout

    The default value for ReadTimeout(TimeSpan): 10 seconds.

    Declaration
    public static readonly TimeSpan DefaultReadTimeout
    Field Value
    Type Description
    TimeSpan
    | Edit this page View Source

    DefaultResponseStartTimeout

    The default value for ResponseStartTimeout(TimeSpan): 10 seconds.

    Declaration
    public static readonly TimeSpan DefaultResponseStartTimeout
    Field Value
    Type Description
    TimeSpan

    Methods

    | Edit this page View Source

    Build(LdClientContext)

    Called internally by the SDK to create an implementation instance. Applications should not need to call this method.

    Declaration
    public HttpConfiguration Build(LdClientContext context)
    Parameters
    Type Name Description
    LdClientContext context

    provides configuration properties and other components from the current SDK client instance

    Returns
    Type Description
    HttpConfiguration

    a instance of the component type

    | Edit this page View Source

    ConnectTimeout(TimeSpan)

    Sets the network connection timeout.

    Declaration
    public HttpConfigurationBuilder ConnectTimeout(TimeSpan connectTimeout)
    Parameters
    Type Name Description
    TimeSpan connectTimeout

    the timeout

    Returns
    Type Description
    HttpConfigurationBuilder

    the builder

    Remarks

    This is the time allowed for the underlying HTTP client to connect to the LaunchDarkly server, for any individual network connection.

    It is not the same as StartWaitTime(TimeSpan), which limits the time for initializing the SDK regardless of how many individual HTTP requests are done in that time.

    Not all .NET platforms support setting a connection timeout. It is implemented as a property of System.Net.Http.SocketsHttpHandler in .NET Core 2.1+ and .NET 5+, but is unavailable in .NET Framework and .NET Standard. On platforms where it is not supported, only ResponseStartTimeout(TimeSpan) will be used.

    Also, since this is implemented only in SocketsHttpHandler, if you have specified some other HTTP handler implementation with HttpMessageHandler, the ConnectTimeout(TimeSpan) here will be ignored.

    See Also
    ResponseStartTimeout(TimeSpan)
    | Edit this page View Source

    CustomHeader(string, string)

    Specifies a custom HTTP header that should be added to all SDK requests.

    Declaration
    public HttpConfigurationBuilder CustomHeader(string name, string value)
    Parameters
    Type Name Description
    string name

    the header name

    string value

    the header value

    Returns
    Type Description
    HttpConfigurationBuilder

    the builder

    Remarks

    This may be helpful if you are using a gateway or proxy server that requires a specific header in requests. You may add any number of headers.

    | Edit this page View Source

    DescribeConfiguration(LdClientContext)

    Called internally by the SDK to inspect the configuration. Applications do not need to call this method.

    Declaration
    public LdValue DescribeConfiguration(LdClientContext context)
    Parameters
    Type Name Description
    LdClientContext context

    SDK configuration/component information

    Returns
    Type Description
    LdValue

    a JSON value

    | Edit this page View Source

    MessageHandler(HttpMessageHandler)

    Specifies a custom HTTP message handler implementation.

    Declaration
    public HttpConfigurationBuilder MessageHandler(HttpMessageHandler messageHandler)
    Parameters
    Type Name Description
    HttpMessageHandler messageHandler

    the message handler, or null to use the platform's default handler

    Returns
    Type Description
    HttpConfigurationBuilder

    the builder

    Remarks

    This is mainly useful for testing, to cause the SDK to use custom logic instead of actual HTTP requests, but can also be used to customize HTTP behavior on platforms where .NET's default handler is not optimal.

    | Edit this page View Source

    Proxy(IWebProxy)

    Sets an HTTP proxy for making connections to LaunchDarkly.

    Declaration
    public HttpConfigurationBuilder Proxy(IWebProxy proxy)
    Parameters
    Type Name Description
    IWebProxy proxy

    any implementation of System.Net.IWebProxy

    Returns
    Type Description
    HttpConfigurationBuilder

    the builder

    Remarks

    This is ignored if you have specified a custom message handler with MessageHandler(HttpMessageHandler), since proxy behavior is implemented by the message handler.

    Note that this is not the same as the LaunchDarkly Relay Proxy, which would be set with RelayProxy(Uri).

    Examples
    // Example of using an HTTP proxy with basic authentication
    
    var proxyUri = new Uri("http://my-proxy-host:8080");
    var proxy = new System.Net.WebProxy(proxyUri);
    var credentials = new System.Net.CredentialCache();
    credentials.Add(proxyUri, "Basic",
        new System.Net.NetworkCredential("username", "password"));
    proxy.Credentials = credentials;
    
    var config = Configuration.Builder("my-sdk-key")
        .Http(
            Components.HttpConfiguration().Proxy(proxy)
        )
        .Build();
    | Edit this page View Source

    ReadTimeout(TimeSpan)

    Sets the socket read timeout.

    Declaration
    public HttpConfigurationBuilder ReadTimeout(TimeSpan readTimeout)
    Parameters
    Type Name Description
    TimeSpan readTimeout

    the socket read timeout

    Returns
    Type Description
    HttpConfigurationBuilder

    the builder

    Remarks

    Sets the socket timeout. This is the amount of time without receiving data on a connection that the SDK will tolerate before signaling an error. This does not apply to the streaming connection used by StreamingDataSource(), which has its own non-configurable read timeout based on the expected behavior of the LaunchDarkly streaming service.

    | Edit this page View Source

    ResponseStartTimeout(TimeSpan)

    Sets the maximum amount of time to wait for the beginning of an HTTP response.

    Declaration
    public HttpConfigurationBuilder ResponseStartTimeout(TimeSpan responseStartTimeout)
    Parameters
    Type Name Description
    TimeSpan responseStartTimeout

    the timeout

    Returns
    Type Description
    HttpConfigurationBuilder

    the builder

    Remarks

    This limits how long the SDK will wait from the time it begins trying to make a network connection for an individual HTTP request to the time it starts receiving any data from the server. It is equivalent to the Timeout property in HttpClient.

    It is not the same as StartWaitTime(TimeSpan), which limits the time for initializing the SDK regardless of how many individual HTTP requests are done in that time.

    See Also
    ConnectTimeout(TimeSpan)
    | Edit this page View Source

    Wrapper(string, string)

    For use by wrapper libraries to set an identifying name for the wrapper being used.

    Declaration
    public HttpConfigurationBuilder Wrapper(string wrapperName, string wrapperVersion)
    Parameters
    Type Name Description
    string wrapperName

    an identifying name for the wrapper library

    string wrapperVersion

    version string for the wrapper library

    Returns
    Type Description
    HttpConfigurationBuilder

    the builder

    Remarks

    This will be included in a header during requests to the LaunchDarkly servers to allow recording metrics on the usage of these wrapper libraries.

    Implements

    IComponentConfigurer<T>
    IDiagnosticDescription
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX