public abstract class HttpClientConfiguration
extends java.lang.Object
HttpClient
.Modifier and Type | Class and Description |
---|---|
static class |
HttpClientConfiguration.ConnectionPoolConfiguration
Configuration for the HTTP client connnection pool.
|
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_EXCEPTION_ON_ERROR_STATUS
The default value.
|
static boolean |
DEFAULT_FOLLOW_REDIRECTS
The default follow redirects value.
|
static int |
DEFAULT_MAX_CONTENT_LENGTH
The default max content length in bytes.
|
static long |
DEFAULT_READ_IDLE_TIMEOUT_MINUTES
The default read idle timeout in minutes.
|
static long |
DEFAULT_READ_TIMEOUT_SECONDS
The default read timeout in seconds.
|
static long |
DEFAULT_SHUTDOWN_TIMEOUT_MILLISECONDS
The default shutdown timeout in millis.
|
Constructor and Description |
---|
HttpClientConfiguration()
Default constructor.
|
HttpClientConfiguration(ApplicationConfiguration applicationConfiguration) |
HttpClientConfiguration(HttpClientConfiguration copy)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
getChannelOptions() |
abstract HttpClientConfiguration.ConnectionPoolConfiguration |
getConnectionPoolConfiguration()
Obtains the connection pool configuration.
|
java.util.Optional<java.time.Duration> |
getConnectTimeout() |
java.util.Optional<java.time.Duration> |
getConnectTtl() |
java.nio.charset.Charset |
getDefaultCharset() |
java.lang.String |
getEventLoopGroup() |
HttpVersion |
getHttpVersion()
The HTTP version to use.
|
java.util.Optional<java.lang.String> |
getLoggerName() |
java.util.Optional<LogLevel> |
getLogLevel() |
int |
getMaxContentLength() |
java.util.OptionalInt |
getNumOfThreads() |
java.util.Optional<java.net.SocketAddress> |
getProxyAddress()
The proxy to use.
|
java.util.Optional<java.lang.String> |
getProxyPassword() |
java.util.Optional<java.net.ProxySelector> |
getProxySelector() |
java.net.Proxy.Type |
getProxyType()
The proxy to use.
|
java.util.Optional<java.lang.String> |
getProxyUsername() |
java.util.Optional<java.time.Duration> |
getReadIdleTimeout()
For streaming requests and WebSockets, the
getReadTimeout() method does not apply instead a configurable
idle timeout is applied. |
java.util.Optional<java.time.Duration> |
getReadTimeout() |
java.util.Optional<java.time.Duration> |
getShutdownTimeout()
The amount of time to wait for shutdown.
|
SslConfiguration |
getSslConfiguration() |
java.util.Optional<java.lang.Class<? extends java.util.concurrent.ThreadFactory>> |
getThreadFactory() |
boolean |
isExceptionOnErrorStatus() |
boolean |
isFollowRedirects() |
java.net.Proxy |
resolveProxy(boolean isSsl,
java.lang.String host,
int port)
Resolves a proxy to use for connection.
|
void |
setChannelOptions(java.util.Map<java.lang.String,java.lang.Object> channelOptions) |
void |
setConnectTimeout(java.time.Duration connectTimeout)
Sets the connect timeout.
|
void |
setConnectTtl(java.time.Duration connectTtl)
Sets the connect timeout.
|
void |
setDefaultCharset(java.nio.charset.Charset defaultCharset)
Sets the default charset to use.
|
void |
setEventLoopGroup(java.lang.String eventLoopGroup) |
void |
setExceptionOnErrorStatus(boolean exceptionOnErrorStatus)
Sets whether throwing an exception upon HTTP error status (>= 400) is preferred.
|
void |
setFollowRedirects(boolean followRedirects)
Sets whether redirects should be followed.
|
void |
setHttpVersion(HttpVersion httpVersion)
Sets the HTTP version to use.
|
void |
setLoggerName(java.lang.String loggerName)
Sets the client-specific logger name.
|
void |
setLogLevel(LogLevel logLevel)
Sets the level to enable trace logging at.
|
void |
setMaxContentLength(int maxContentLength)
Sets the maximum content length the client can consume.
|
void |
setNumOfThreads(java.lang.Integer numOfThreads)
Sets the number of threads the client should use for requests.
|
void |
setProxyAddress(java.net.SocketAddress proxyAddress)
Sets a proxy address.
|
void |
setProxyPassword(java.lang.String proxyPassword)
Sets the proxy password.
|
void |
setProxySelector(java.net.ProxySelector proxySelector)
Sets the proxy selector.
|
void |
setProxyType(java.net.Proxy.Type proxyType) |
void |
setProxyUsername(java.lang.String proxyUsername)
Sets the proxy user name to use.
|
void |
setReadIdleTimeout(java.time.Duration readIdleTimeout)
Sets the max read idle time for streaming requests.
|
void |
setReadTimeout(java.time.Duration readTimeout)
Sets the read timeout.
|
void |
setShutdownTimeout(java.time.Duration shutdownTimeout)
Sets the amount of time to wait for shutdown of client thread pools.
|
void |
setSslConfiguration(SslConfiguration sslConfiguration)
Sets the SSL configuration for the client.
|
void |
setThreadFactory(java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactory)
Sets a thread factory.
|
public static final long DEFAULT_READ_TIMEOUT_SECONDS
public static final long DEFAULT_READ_IDLE_TIMEOUT_MINUTES
public static final long DEFAULT_SHUTDOWN_TIMEOUT_MILLISECONDS
public static final int DEFAULT_MAX_CONTENT_LENGTH
public static final boolean DEFAULT_FOLLOW_REDIRECTS
public static final boolean DEFAULT_EXCEPTION_ON_ERROR_STATUS
public HttpClientConfiguration()
public HttpClientConfiguration(ApplicationConfiguration applicationConfiguration)
applicationConfiguration
- The application configurationpublic HttpClientConfiguration(HttpClientConfiguration copy)
copy
- The client configuration to copy settings frompublic HttpVersion getHttpVersion()
HttpVersion.HTTP_1_1
.public void setHttpVersion(HttpVersion httpVersion)
HttpVersion.HTTP_1_1
.httpVersion
- The http versionpublic java.util.Optional<LogLevel> getLogLevel()
public void setLogLevel(@Nullable LogLevel logLevel)
LoggingHandler
at the given level.logLevel
- The trace logging levelpublic java.lang.String getEventLoopGroup()
public void setEventLoopGroup(@NonNull java.lang.String eventLoopGroup)
eventLoopGroup
- Sets the event loop group to use for the client.public abstract HttpClientConfiguration.ConnectionPoolConfiguration getConnectionPoolConfiguration()
public SslConfiguration getSslConfiguration()
SslConfiguration
for the clientpublic void setSslConfiguration(SslConfiguration sslConfiguration)
sslConfiguration
- The SSL configurationpublic boolean isFollowRedirects()
public boolean isExceptionOnErrorStatus()
public void setExceptionOnErrorStatus(boolean exceptionOnErrorStatus)
DEFAULT_EXCEPTION_ON_ERROR_STATUS
)exceptionOnErrorStatus
- Whetherpublic java.util.Optional<java.lang.String> getLoggerName()
public void setLoggerName(@Nullable java.lang.String loggerName)
loggerName
- The name of the logger.public void setFollowRedirects(boolean followRedirects)
DEFAULT_FOLLOW_REDIRECTS
).followRedirects
- Whether redirects should be followedpublic java.nio.charset.Charset getDefaultCharset()
public void setDefaultCharset(java.nio.charset.Charset defaultCharset)
defaultCharset
- The charset to usepublic java.util.Map<java.lang.String,java.lang.Object> getChannelOptions()
public void setChannelOptions(java.util.Map<java.lang.String,java.lang.Object> channelOptions)
channelOptions
- The Client channel optionspublic java.util.Optional<java.time.Duration> getReadTimeout()
public java.util.Optional<java.time.Duration> getReadIdleTimeout()
getReadTimeout()
method does not apply instead a configurable
idle timeout is applied.public java.util.Optional<java.time.Duration> getConnectTimeout()
public java.util.Optional<java.time.Duration> getConnectTtl()
public java.util.Optional<java.time.Duration> getShutdownTimeout()
public void setShutdownTimeout(@Nullable java.time.Duration shutdownTimeout)
shutdownTimeout
- The shutdown timepublic void setReadTimeout(@Nullable java.time.Duration readTimeout)
readTimeout
- The read timeoutpublic void setReadIdleTimeout(@Nullable java.time.Duration readIdleTimeout)
readIdleTimeout
- The read idle timepublic void setConnectTimeout(@Nullable java.time.Duration connectTimeout)
connectTimeout
- The connect timeoutpublic void setConnectTtl(@Nullable java.time.Duration connectTtl)
connectTtl
- The connect timeoutpublic java.util.OptionalInt getNumOfThreads()
public void setNumOfThreads(@Nullable java.lang.Integer numOfThreads)
numOfThreads
- The number of threads the client should use for requestspublic java.util.Optional<java.lang.Class<? extends java.util.concurrent.ThreadFactory>> getThreadFactory()
Optional
ThreadFactory
public void setThreadFactory(java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactory)
threadFactory
- The thread factorypublic int getMaxContentLength()
public void setMaxContentLength(@ReadableBytes int maxContentLength)
maxContentLength
- The maximum content length the client can consumepublic java.net.Proxy.Type getProxyType()
Alternatively configure a java.net.ProxySelector
public void setProxyType(java.net.Proxy.Type proxyType)
proxyType
- The proxy typepublic java.util.Optional<java.net.SocketAddress> getProxyAddress()
Alternatively configure a java.net.ProxySelector
public void setProxyAddress(java.net.SocketAddress proxyAddress)
proxyAddress
- The proxy addresspublic java.util.Optional<java.lang.String> getProxyUsername()
public void setProxyUsername(java.lang.String proxyUsername)
proxyUsername
- The proxy user name to usepublic java.util.Optional<java.lang.String> getProxyPassword()
public void setProxyPassword(java.lang.String proxyPassword)
proxyPassword
- The proxy passwordpublic void setProxySelector(java.net.ProxySelector proxySelector)
setProxyAddress(SocketAddress)
and setProxyType(Proxy.Type)
.proxySelector
- The proxy selector to usepublic java.util.Optional<java.net.ProxySelector> getProxySelector()
public java.net.Proxy resolveProxy(boolean isSsl, java.lang.String host, int port)
If ProxySelector is set by setProxySelector(ProxySelector)
then it constructs URI and pass it to ProxySelector.select(URI)
.
First proxy returned by proxy selector will be used. If no proxy is returned by select, then Proxy.NO_PROXY
will be used.
If ProxySelector is not set then parameters are ignored and a proxy as defined by setProxyAddress(SocketAddress)
and setProxyType(Proxy.Type)
will be returned.
If no proxy is defined then parameters are ignored and Proxy.NO_PROXY
is returned.
isSsl
- is it http or https connectionhost
- connection hostport
- connection port