Class HttpConfigurationBuilder
- java.lang.Object
-
- com.launchdarkly.sdk.server.integrations.HttpConfigurationBuilder
-
- All Implemented Interfaces:
ComponentConfigurer<HttpConfiguration>
public abstract class HttpConfigurationBuilder extends java.lang.Object implements ComponentConfigurer<HttpConfiguration>
Contains methods for configuring the SDK's networking behavior.If you want to set non-default values for any of these properties, create a builder with
Components.httpConfiguration(), change its properties with the methods of this class, and pass it toLDConfig.Builder.http(ComponentConfigurer):LDConfig config = new LDConfig.Builder() .http( Components.httpConfiguration() .connectTimeoutMillis(3000) .proxyHostAndPort("my-proxy", 8080) ) .build();Note that this class is abstract; the actual implementation is created by calling
Components.httpConfiguration().- Since:
- 4.13.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.time.DurationconnectTimeoutprotected java.util.Map<java.lang.String,java.lang.String>customHeadersstatic java.time.DurationDEFAULT_CONNECT_TIMEOUTThe default value forconnectTimeout(Duration): two seconds.static java.time.DurationDEFAULT_SOCKET_TIMEOUTThe default value forsocketTimeout(Duration): 10 seconds.protected HttpAuthenticationproxyAuthprotected java.lang.StringproxyHostprotected intproxyPortprotected javax.net.SocketFactorysocketFactoryprotected java.time.DurationsocketTimeoutprotected javax.net.ssl.SSLSocketFactorysslSocketFactoryprotected javax.net.ssl.X509TrustManagertrustManagerprotected java.lang.StringwrapperNameprotected java.lang.StringwrapperVersion
-
Constructor Summary
Constructors Constructor Description HttpConfigurationBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpConfigurationBuilderaddCustomHeader(java.lang.String headerName, java.lang.String headerValue)Specifies a custom HTTP header that should be added to all SDK requests.HttpConfigurationBuilderconnectTimeout(java.time.Duration connectTimeout)Sets the connection timeout.HttpConfigurationBuilderproxyAuth(HttpAuthentication strategy)Sets an authentication strategy for use with an HTTP proxy.HttpConfigurationBuilderproxyHostAndPort(java.lang.String host, int port)Sets an HTTP proxy for making connections to LaunchDarkly.HttpConfigurationBuildersocketFactory(javax.net.SocketFactory socketFactory)Specifies a custom socket configuration for HTTP connections to LaunchDarkly.HttpConfigurationBuildersocketTimeout(java.time.Duration socketTimeout)Sets the socket timeout.HttpConfigurationBuildersslSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory, javax.net.ssl.X509TrustManager trustManager)Specifies a custom security configuration for HTTPS connections to LaunchDarkly.HttpConfigurationBuilderwrapper(java.lang.String wrapperName, java.lang.String wrapperVersion)For use by wrapper libraries to set an identifying name for the wrapper being used.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.launchdarkly.sdk.server.subsystems.ComponentConfigurer
build
-
-
-
-
Field Detail
-
DEFAULT_CONNECT_TIMEOUT
public static final java.time.Duration DEFAULT_CONNECT_TIMEOUT
The default value forconnectTimeout(Duration): two seconds.
-
DEFAULT_SOCKET_TIMEOUT
public static final java.time.Duration DEFAULT_SOCKET_TIMEOUT
The default value forsocketTimeout(Duration): 10 seconds.
-
connectTimeout
protected java.time.Duration connectTimeout
-
proxyAuth
protected HttpAuthentication proxyAuth
-
proxyHost
protected java.lang.String proxyHost
-
customHeaders
protected java.util.Map<java.lang.String,java.lang.String> customHeaders
-
proxyPort
protected int proxyPort
-
socketTimeout
protected java.time.Duration socketTimeout
-
socketFactory
protected javax.net.SocketFactory socketFactory
-
sslSocketFactory
protected javax.net.ssl.SSLSocketFactory sslSocketFactory
-
trustManager
protected javax.net.ssl.X509TrustManager trustManager
-
wrapperName
protected java.lang.String wrapperName
-
wrapperVersion
protected java.lang.String wrapperVersion
-
-
Method Detail
-
connectTimeout
public HttpConfigurationBuilder connectTimeout(java.time.Duration connectTimeout)
Sets the connection timeout. This is the time allowed for the SDK to make a socket connection to any of the LaunchDarkly services.The default is
DEFAULT_CONNECT_TIMEOUT.- Parameters:
connectTimeout- the connection timeout; null to use the default- Returns:
- the builder
-
proxyHostAndPort
public HttpConfigurationBuilder proxyHostAndPort(java.lang.String host, int port)
Sets an HTTP proxy for making connections to LaunchDarkly.- Parameters:
host- the proxy hostnameport- the proxy port- Returns:
- the builder
-
proxyAuth
public HttpConfigurationBuilder proxyAuth(HttpAuthentication strategy)
Sets an authentication strategy for use with an HTTP proxy. This has no effect unless a proxy was specified withproxyHostAndPort(String, int).- Parameters:
strategy- the authentication strategy- Returns:
- the builder
-
socketTimeout
public HttpConfigurationBuilder socketTimeout(java.time.Duration socketTimeout)
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 byComponents.streamingDataSource(), which has its own non-configurable read timeout based on the expected behavior of the LaunchDarkly streaming service.The default is
DEFAULT_SOCKET_TIMEOUT.- Parameters:
socketTimeout- the socket timeout; null to use the default- Returns:
- the builder
-
socketFactory
public HttpConfigurationBuilder socketFactory(javax.net.SocketFactory socketFactory)
Specifies a custom socket configuration for HTTP connections to LaunchDarkly.This uses the standard Java interfaces for configuring socket connections.
- Parameters:
socketFactory- the socket factory- Returns:
- the builder
-
sslSocketFactory
public HttpConfigurationBuilder sslSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory, javax.net.ssl.X509TrustManager trustManager)
Specifies a custom security configuration for HTTPS connections to LaunchDarkly.This uses the standard Java interfaces for configuring secure socket connections and certificate verification.
- Parameters:
sslSocketFactory- the SSL socket factorytrustManager- the trust manager- Returns:
- the builder
-
addCustomHeader
public HttpConfigurationBuilder addCustomHeader(java.lang.String headerName, java.lang.String headerValue)
Specifies a custom HTTP header that should be added to all SDK requests.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.
- Parameters:
headerName- standard HTTP headerheaderValue- standard HTTP value- Returns:
- the builder
-
wrapper
public HttpConfigurationBuilder wrapper(java.lang.String wrapperName, java.lang.String wrapperVersion)
For use by wrapper libraries to set an identifying name for the wrapper being used. This will be included in a header during requests to the LaunchDarkly servers to allow recording metrics on the usage of these wrapper libraries.- Parameters:
wrapperName- an identifying name for the wrapper librarywrapperVersion- version string for the wrapper library- Returns:
- the builder
-
-