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 boolean |
DEFAULT_FOLLOW_REDIRECTS
The default follow redirects value.
|
static int |
DEFAULT_MAX_CONTENT_LENGTH
The default shutdown timeout in millis.
|
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) |
| Modifier and Type | Method and Description |
|---|---|
Map<io.netty.channel.ChannelOption,Object> |
getChannelOptions() |
abstract HttpClientConfiguration.ConnectionPoolConfiguration |
getConnectionPoolConfiguration()
Obtains the connection pool configuration.
|
Optional<Duration> |
getConnectTimeout() |
Optional<Duration> |
getConnectTtl() |
Charset |
getDefaultCharset() |
Optional<String> |
getLoggerName() |
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> |
getShutdownTimeout()
The amount of time to wait for shutdown.
|
SslConfiguration |
getSslConfiguration() |
Optional<Class<? extends ThreadFactory>> |
getThreadFactory() |
boolean |
isFollowRedirects() |
Proxy |
resolveProxy(boolean isSsl,
String host,
int port)
Resolves a proxy to use for connection.
|
void |
setChannelOptions(Map<io.netty.channel.ChannelOption,Object> channelOptions) |
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 |
setFollowRedirects(boolean followRedirects)
Sets whether redirects should be followed.
|
void |
setLoggerName(String loggerName)
Sets the client-specific logger name.
|
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 |
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_SHUTDOWN_TIMEOUT_MILLISECONDS
public static final int DEFAULT_MAX_CONTENT_LENGTH
public static final boolean DEFAULT_FOLLOW_REDIRECTS
public HttpClientConfiguration()
public HttpClientConfiguration(ApplicationConfiguration applicationConfiguration)
applicationConfiguration - The application configurationpublic abstract HttpClientConfiguration.ConnectionPoolConfiguration getConnectionPoolConfiguration()
public SslConfiguration getSslConfiguration()
SslConfiguration for the clientpublic void setSslConfiguration(SslConfiguration sslConfiguration)
sslConfiguration - The SSL configurationpublic boolean isFollowRedirects()
public 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<io.netty.channel.ChannelOption,Object> getChannelOptions()
AbstractBootstrap.options()public void setChannelOptions(Map<io.netty.channel.ChannelOption,Object> channelOptions)
channelOptions - The Netty channel optionsAbstractBootstrap.options()public Optional<Duration> getReadTimeout()
public Optional<Duration> getReadIdleTimeout()
getReadTimeout() method does not apply instead a configurable
idle timeout is applied.public Optional<Duration> getConnectTimeout()
public Optional<Duration> getShutdownTimeout()
public 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 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)
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