public abstract class HttpClientConfiguration extends 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 long |
DEFAULT_CONNECTION_POOL_IDLE_TIMEOUT_SECONDS
The default pool idle timeout in seconds.
|
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_QUIET_PERIOD_MILLISECONDS
The default shutdown timeout in millis.
|
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 |
|---|---|
Map<String,Object> |
getChannelOptions() |
abstract HttpClientConfiguration.ConnectionPoolConfiguration |
getConnectionPoolConfiguration()
Obtains the connection pool configuration.
|
Optional<Duration> |
getConnectionPoolIdleTimeout() |
Optional<Duration> |
getConnectTimeout() |
Optional<Duration> |
getConnectTtl() |
Charset |
getDefaultCharset() |
String |
getEventLoopGroup() |
HttpVersion |
getHttpVersion()
The HTTP version to use.
|
Optional<String> |
getLoggerName() |
Optional<LogLevel> |
getLogLevel() |
int |
getMaxContentLength() |
OptionalInt |
getNumOfThreads() |
Optional<SocketAddress> |
getProxyAddress()
The proxy to use.
|
Optional<String> |
getProxyPassword() |
Optional<ProxySelector> |
getProxySelector() |
Proxy.Type |
getProxyType()
The proxy to use.
|
Optional<String> |
getProxyUsername() |
Optional<Duration> |
getReadIdleTimeout()
For streaming requests and WebSockets, the
getReadTimeout() method does not apply instead a configurable
idle timeout is applied. |
Optional<Duration> |
getReadTimeout() |
Optional<Duration> |
getShutdownQuietPeriod()
The amount of quiet period for shutdown.
|
Optional<Duration> |
getShutdownTimeout()
The amount of time to wait for shutdown.
|
SslConfiguration |
getSslConfiguration() |
Optional<Class<? extends ThreadFactory>> |
getThreadFactory() |
boolean |
isExceptionOnErrorStatus() |
boolean |
isFollowRedirects() |
Proxy |
resolveProxy(boolean isSsl,
String host,
int port)
Resolves a proxy to use for connection.
|
void |
setChannelOptions(Map<String,Object> channelOptions) |
void |
setConnectionPoolIdleTimeout(Duration connectionPoolIdleTimeout)
Sets the idle timeout for connection in the client connection pool.
|
void |
setConnectTimeout(Duration connectTimeout)
Sets the connect timeout.
|
void |
setConnectTtl(Duration connectTtl)
Sets the connect timeout.
|
void |
setDefaultCharset(Charset defaultCharset)
Sets the default charset to use.
|
void |
setEventLoopGroup(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(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(Integer numOfThreads)
Sets the number of threads the client should use for requests.
|
void |
setProxyAddress(SocketAddress proxyAddress)
Sets a proxy address.
|
void |
setProxyPassword(String proxyPassword)
Sets the proxy password.
|
void |
setProxySelector(ProxySelector proxySelector)
Sets the proxy selector.
|
void |
setProxyType(Proxy.Type proxyType) |
void |
setProxyUsername(String proxyUsername)
Sets the proxy user name to use.
|
void |
setReadIdleTimeout(Duration readIdleTimeout)
Sets the max read idle time for streaming requests.
|
void |
setReadTimeout(Duration readTimeout)
Sets the read timeout.
|
void |
setShutdownQuietPeriod(Duration shutdownQuietPeriod)
Sets the amount of quiet period for shutdown of client thread pools.
|
void |
setShutdownTimeout(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(Class<? extends 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_CONNECTION_POOL_IDLE_TIMEOUT_SECONDS
public static final long DEFAULT_SHUTDOWN_QUIET_PERIOD_MILLISECONDS
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 void setLogLevel(@Nullable LogLevel logLevel)
LoggingHandler at the given level.logLevel - The trace logging levelpublic String getEventLoopGroup()
public void setEventLoopGroup(@NonNull 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 Optional<String> getLoggerName()
public void setLoggerName(@Nullable String loggerName)
loggerName - The name of the logger.public void setFollowRedirects(boolean followRedirects)
DEFAULT_FOLLOW_REDIRECTS).followRedirects - Whether redirects should be followedpublic Charset getDefaultCharset()
public void setDefaultCharset(Charset defaultCharset)
defaultCharset - The charset to usepublic Map<String,Object> getChannelOptions()
public void setChannelOptions(Map<String,Object> channelOptions)
channelOptions - The Client channel optionspublic Optional<Duration> getReadTimeout()
public Optional<Duration> getReadIdleTimeout()
getReadTimeout() method does not apply instead a configurable
idle timeout is applied.public Optional<Duration> getConnectionPoolIdleTimeout()
public Optional<Duration> getConnectTimeout()
public Optional<Duration> getShutdownQuietPeriod()
public Optional<Duration> getShutdownTimeout()
public void setShutdownQuietPeriod(@Nullable Duration shutdownQuietPeriod)
shutdownQuietPeriod - The shutdown quiet periodpublic void setShutdownTimeout(@Nullable Duration shutdownTimeout)
shutdownTimeout - The shutdown timepublic void setReadTimeout(@Nullable Duration readTimeout)
readTimeout - The read timeoutpublic void setReadIdleTimeout(@Nullable Duration readIdleTimeout)
readIdleTimeout - The read idle timepublic void setConnectionPoolIdleTimeout(@Nullable Duration connectionPoolIdleTimeout)
connectionPoolIdleTimeout - The connection pool idle timeoutpublic void setConnectTimeout(@Nullable Duration connectTimeout)
connectTimeout - The connect timeoutpublic void setConnectTtl(@Nullable Duration connectTtl)
connectTtl - The connect timeoutpublic OptionalInt getNumOfThreads()
public void setNumOfThreads(@Nullable Integer numOfThreads)
numOfThreads - The number of threads the client should use for requestspublic Optional<Class<? extends ThreadFactory>> getThreadFactory()
Optional ThreadFactorypublic void setThreadFactory(Class<? extends ThreadFactory> threadFactory)
threadFactory - The thread factorypublic int getMaxContentLength()
public void setMaxContentLength(@ReadableBytes int maxContentLength)
maxContentLength - The maximum content length the client can consumepublic Proxy.Type getProxyType()
Alternatively configure a java.net.ProxySelector
public void setProxyType(Proxy.Type proxyType)
proxyType - The proxy typepublic Optional<SocketAddress> getProxyAddress()
Alternatively configure a java.net.ProxySelector
public void setProxyAddress(SocketAddress proxyAddress)
proxyAddress - The proxy addresspublic void setProxyUsername(String proxyUsername)
proxyUsername - The proxy user name to usepublic void setProxyPassword(String proxyPassword)
proxyPassword - The proxy passwordpublic void setProxySelector(ProxySelector proxySelector)
setProxyAddress(SocketAddress) and setProxyType(Proxy.Type).proxySelector - The proxy selector to usepublic Optional<ProxySelector> getProxySelector()
public Proxy resolveProxy(boolean isSsl, 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