Class HttpClientConfig
- Direct Known Subclasses:
WebClientConfig
HttpClient- Author:
- Julien Viet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final List<HttpVersion> -
Constructor Summary
ConstructorsConstructorDescriptionHttpClientConfig(HttpClientConfig other) HttpClientConfig(HttpClientOptions options) -
Method Summary
Modifier and TypeMethodDescriptionGet the default host name to be used by this client in requests if none is provided when making the request.intGet the default port to be used by this client in requests if none is provided when making the request.booleanintgetName()booleanbooleanisShared()booleanisSsl()booleanIs hostname verification (for SSL/TLS) enabled?setConnectTimeout(Duration connectTimeout) Set the connect timeoutsetDecompressionEnabled(boolean decompressionEnabled) Whether the client should send requests with anaccepting-encodingheader set to a compression algorithm.setDefaultHost(String defaultHost) Set the default host name to be used by this client in requests if none is provided when making the request.setDefaultPort(int defaultPort) Set the default port to be used by this client in requests if none is provided when making the request.setFollowAlternativeServices(boolean followAlternativeServices) Configure whether the client follows alternative services advertisements, the default setting does not.setHttp1Config(Http1ClientConfig config) Set the HTTP/1.x configuration to usesetHttp2Config(Http2ClientConfig config) Set the HTTP/2 configuration to usesetHttp3Config(Http3ClientConfig config) Set the HTTP/2 configuration to usesetIdleTimeout(Duration idleTimeout) Set the idle timeout, zero ornullmeans don't time out.setKeepAliveTimeout(Duration keepAliveTimeout) Set the keep alive timeout for HTTP connections.setLogConfig(LogConfig config) Configure the per stream networking logging: Netty's stream pipeline is configured for logging on Netty's logger.setMaxRedirects(int maxRedirects) Set tomaxRedirectsthe maximum number of redirection a request can follow.Set the client name, used when the client is shared, otherwise ignored.setObservabilityConfig(ObservabilityConfig observabilityConfig) Set the client observability config.setReadIdleTimeout(Duration idleTimeout) Set the read idle timeout, zero ornullmeans or null means don't time out.setShared(boolean shared) Set totrueto share the client.setSsl(boolean ssl) Set whether SSL/TLS is enabledsetVerifyHost(boolean verifyHost) Set whether hostname verification is enabledsetVersions(HttpVersion... versions) LikesetVersions(List)using an array.setVersions(List<HttpVersion> versions) Set the list ofHttpVersionsupported by the client, the first element of the list is considered as the default protocol to choose when none is specified at the request level.setWriteIdleTimeout(Duration idleTimeout) Set the write idle timeout, zero ornullmeans don't time out.
-
Field Details
-
DEFAULT_SUPPORTED_VERSIONS
-
DEFAULT_QUIC_INITIAL_MAX_DATA
public static final long DEFAULT_QUIC_INITIAL_MAX_DATA- See Also:
-
DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL
public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL- See Also:
-
DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE
public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE- See Also:
-
DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_UNI
public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_UNI- See Also:
-
DEFAULT_QUIC_INITIAL_MAX_STREAM_BIDI
public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_BIDI- See Also:
-
DEFAULT_QUIC_INITIAL_MAX_STREAM_UNI
public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_UNI- See Also:
-
-
Constructor Details
-
HttpClientConfig
public HttpClientConfig() -
HttpClientConfig
-
HttpClientConfig
-
-
Method Details
-
getTcpConfig
- Returns:
- the client TCP transport config
-
getQuicConfig
- Returns:
- the client QUIC transport config
-
setConnectTimeout
Set the connect timeout- Parameters:
connectTimeout- connect timeout, in ms- Returns:
- a reference to this, so the API can be used fluently
-
setKeepAliveTimeout
Set the keep alive timeout for HTTP connections. This value determines how long a connection remains unused in the pool before being evicted and closed. A timeout of zero or
nullmeans there is no timeout.This configures each HTTP version with the same value, you can override this and configure each version separately.
- Parameters:
keepAliveTimeout- the timeout, in seconds- Returns:
- a reference to this, so the API can be used fluently
-
setIdleTimeout
Set the idle timeout, zero ornullmeans don't time out. This determines if a connection will timeout and be closed if no data is received nor sent within the timeout.This configures both TCP and QUIC nested configurations, you can configure each of them separately if you need to.
- Parameters:
idleTimeout- the timeout- Returns:
- a reference to this, so the API can be used fluently
-
setReadIdleTimeout
Set the read idle timeout, zero or
nullmeans or null means don't time out. This determines if a connection will timeout and be closed if no data is received within the timeout.This configures both TCP and QUIC nested configurations, you can configure each of them separately if you need to.
- Parameters:
idleTimeout- the read timeout- Returns:
- a reference to this, so the API can be used fluently
-
setWriteIdleTimeout
Set the write idle timeout, zero or
nullmeans don't time out. This determines if a connection will timeout and be closed if no data is sent within the timeout.This configures both TCP and QUIC nested configurations, you can configure each of them separately if you need to.
- Parameters:
idleTimeout- the write timeout- Returns:
- a reference to this, so the API can be used fluently
-
setLogConfig
Configure the per stream networking logging: Netty's stream pipeline is configured for logging on Netty's logger.
This configures both TCP and QUIC nested configurations, you can configure each of them separately if you need to.
- Parameters:
config- the stream network logging config,nullmeans disabled- Returns:
- a reference to this, so the API can be used fluently
-
isSsl
public boolean isSsl()- Returns:
- is SSL/TLS enabled?
-
setSsl
Set whether SSL/TLS is enabled- Parameters:
ssl- true if enabled- Returns:
- a reference to this, so the API can be used fluently
-
getVersions
- Returns:
- the ordered list of the versions supported by the client
-
setVersions
Set the list of
HttpVersionsupported by the client, the first element of the list is considered as the default protocol to choose when none is specified at the request level.- Parameters:
versions- the ordered list of supported versions- Returns:
- a reference to this, so the API can be used fluently
-
setVersions
LikesetVersions(List)using an array.- Parameters:
versions- the ordered list of supported versions- Returns:
- a reference to this, so the API can be used fluently
-
getHttp1Config
- Returns:
- the configuration specific to the HTTP/1.x protocol.
-
setHttp1Config
Set the HTTP/1.x configuration to use- Parameters:
config- the config- Returns:
- a reference to this, so the API can be used fluently
-
getHttp2Config
- Returns:
- the configuration specific to the HTTP/2 protocol.
-
setHttp2Config
Set the HTTP/2 configuration to use- Parameters:
config- the config- Returns:
- a reference to this, so the API can be used fluently
-
getHttp3Config
- Returns:
- the configuration specific to the HTTP/3 protocol.
-
setHttp3Config
Set the HTTP/2 configuration to use- Parameters:
config- the config- Returns:
- a reference to this, so the API can be used fluently
-
isVerifyHost
public boolean isVerifyHost()Is hostname verification (for SSL/TLS) enabled?- Returns:
trueif enabled
-
setVerifyHost
Set whether hostname verification is enabled- Parameters:
verifyHost-trueif enabled- Returns:
- a reference to this, so the API can be used fluently
-
isDecompressionEnabled
public boolean isDecompressionEnabled()- Returns:
trueif the client should send requests with anaccepting-encodingheader set to a compression algorithm,falseotherwise
-
setDecompressionEnabled
Whether the client should send requests with anaccepting-encodingheader set to a compression algorithm.- Parameters:
decompressionEnabled-trueif the client should send a request with anaccepting-encodingheader set to a compression algorithm,falseotherwise- Returns:
- a reference to this, so the API can be used fluently
-
getDefaultHost
Get the default host name to be used by this client in requests if none is provided when making the request.- Returns:
- the default host name
-
setDefaultHost
Set the default host name to be used by this client in requests if none is provided when making the request.- Returns:
- a reference to this, so the API can be used fluently
-
getDefaultPort
public int getDefaultPort()Get the default port to be used by this client in requests if none is provided when making the request.- Returns:
- the default port
-
setDefaultPort
Set the default port to be used by this client in requests if none is provided when making the request.- Returns:
- a reference to this, so the API can be used fluently
-
getMaxRedirects
public int getMaxRedirects()- Returns:
- the maximum number of redirection a request can follow
-
setMaxRedirects
Set tomaxRedirectsthe maximum number of redirection a request can follow.- Parameters:
maxRedirects- the maximum number of redirection- Returns:
- a reference to this, so the API can be used fluently
-
getObservabilityConfig
- Returns:
- the client observability config.
-
setObservabilityConfig
Set the client observability config.- Parameters:
observabilityConfig- the server observability config- Returns:
- a reference to this, so the API can be used fluently
-
getName
- Returns:
- the client name used for sharing
-
setName
Set the client name, used when the client is shared, otherwise ignored.- Parameters:
name- the new name- Returns:
- a reference to this, so the API can be used fluently
-
getFollowAlternativeServices
public boolean getFollowAlternativeServices()- Returns:
- whether the client follows alternative services advertisements
-
setFollowAlternativeServices
Configure whether the client follows alternative services advertisements, the default setting does not.
Setting this to true, instructs the client to use most appropriate alternative services advertised by HTTP servers.
The client only follows alternative services it can trust for a given origin, in practice this means this only the
httpsscheme is supported and alternatives handshake uses the alternative origin.- Parameters:
followAlternativeServices- the config value
-