public class Config extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CONNECT_TIMEOUT |
static int |
DEFAULT_CONNECTION_TIMEOUT |
static int |
DEFAULT_MAX_CONNECTIONS |
static int |
DEFAULT_MAX_PER_ROUTE |
static int |
DEFAULT_SOCKET_TIMEOUT |
| Constructor and Description |
|---|
Config() |
| Modifier and Type | Method and Description |
|---|---|
Config |
addDefaultHeader(String name,
String value)
Add default header to appear on all requests
|
Config |
addInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
Add a HttpRequestInterceptor to the clients.
|
Config |
asyncClient(AsyncClient value)
Set the full async configuration including monitors.
|
Config |
asyncClient(java.util.function.Function<Config,AsyncClient> asyncClientBuilder)
Set the full async configuration including monitors.
|
Config |
asyncClient(org.apache.http.nio.client.HttpAsyncClient value)
Set the asynchronous AbstractHttpAsyncClient implementation to use for every asynchronous request
|
Config |
clearDefaultHeaders()
Clear default headers
|
Config |
concurrency(int total,
int perRoute)
Set the concurrency levels
|
Config |
connectTimeout(int inMillies)
Set the connection timeout
|
Config |
enableCookieManagement(boolean enable)
Allow the client to manage cookies.
|
Config |
followRedirects(boolean enable)
Allow the client to follow redirects.
|
AsyncClient |
getAsyncClient()
Return the current HttpAsyncClient.
|
Client |
getClient()
Return the current Client.
|
Headers |
getDefaultHeaders()
Return default headers that are added to every request
|
Config |
httpClient(Client httpClient)
Set the HttpClient implementation to use for every synchronous request
|
Config |
httpClient(java.util.function.Function<Config,Client> httpClient)
Provide a builder for a client
|
Config |
httpClient(org.apache.http.client.HttpClient httpClient)
Set the HttpClient implementation to use for every synchronous request
|
boolean |
isRunning()
Does the config have currently running clients? Find out here.
|
Config |
proxy(org.apache.http.HttpHost value)
Set a proxy
|
Config |
proxy(String host,
int port)
Set a proxy
|
Config |
proxy(String host,
int port,
String username,
String password)
Set an authenticated proxy
|
Config |
reset()
Shutdown the current config and re-init.
|
Config |
setDefaultHeader(String name,
String value)
Set default header to appear on all requests
|
Config |
setDefaultHeader(String name,
java.util.function.Supplier<String> value)
Set default header to appear on all requests, value is through a Supplier
This is useful for adding tracing elements to requests.
|
Config |
setDefaultResponseEncoding(String value)
Set the default encoding that will be used for serialization into Strings.
|
Config |
setObjectMapper(ObjectMapper om)
Set the ObjectMapper implementation to use for Response to Object binding
|
void |
shutDown(boolean clearOptions)
Shut down the configuration and its clients.
|
Config |
socketTimeout(int inMillies)
Set the socket timeout
|
Config |
useSystemProperties(boolean value)
Tell the HttpClients to use the system properties for things like proxies
|
public static final int DEFAULT_CONNECTION_TIMEOUT
public static final int DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_MAX_PER_ROUTE
public static final int DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_SOCKET_TIMEOUT
public Config httpClient(org.apache.http.client.HttpClient httpClient)
httpClient - Custom httpClient implementationpublic Config httpClient(Client httpClient)
httpClient - Custom httpClient implementationpublic Config httpClient(java.util.function.Function<Config,Client> httpClient)
httpClient - Custom httpClient implementationpublic Config asyncClient(org.apache.http.nio.client.HttpAsyncClient value)
value - Custom CloseableHttpAsyncClient implementationpublic Config asyncClient(AsyncClient value)
value - Custom AsyncConfig class. The actual AsyncHttpClient is required.public Config asyncClient(java.util.function.Function<Config,AsyncClient> asyncClientBuilder)
asyncClientBuilder - A builder function for creating a AsyncClientpublic Config proxy(org.apache.http.HttpHost value)
value - Proxy settings object.public Config proxy(String host, int port)
host - the hostname of the proxy server.port - the port of the proxy serverpublic Config proxy(String host, int port, String username, String password)
host - the hostname of the proxy server.port - the port of the proxy serverusername - username for authenticated proxypassword - password for authenticated proxypublic Config setObjectMapper(ObjectMapper om)
om - Custom implementation of ObjectMapper interfacepublic Config connectTimeout(int inMillies)
inMillies - The timeout until a connection with the server is established (in milliseconds). Default is 10000. Set to zero to disable the timeout.public Config socketTimeout(int inMillies)
inMillies - The timeout to receive data (in milliseconds). Default is 60000. Set to zero to disable the timeout.public Config concurrency(int total, int perRoute)
total - Defines the overall connection limit for a connection pool. Default is 200.perRoute - Defines a connection limit per one HTTP route (this can be considered a per target host limit). Default is 20.public Config clearDefaultHeaders()
public Config setDefaultHeader(String name, String value)
name - The name of the header.value - The value of the header.public Config setDefaultHeader(String name, java.util.function.Supplier<String> value)
name - The name of the header.value - a supplier that will get called as part of the request.public Config addDefaultHeader(String name, String value)
name - The name of the header.value - The value of the header.public Config addInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
interceptor - The addInterceptorpublic Config followRedirects(boolean enable)
enable - The name of the header.public Config enableCookieManagement(boolean enable)
enable - The name of the header.public Config useSystemProperties(boolean value)
value - a bool is its true or not.public Config setDefaultResponseEncoding(String value)
value - a bool is its true or not.public Headers getDefaultHeaders()
public boolean isRunning()
public Config reset()
public void shutDown(boolean clearOptions)
clearOptions - should the current non-client settings be retained.public Client getClient()
public AsyncClient getAsyncClient()
Copyright © 2019. All rights reserved.