public class HttpClientUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
HttpClientUtil.HttpClientFactory |
Modifier and Type | Field and Description |
---|---|
static String |
PROP_ALLOW_COMPRESSION |
static String |
PROP_BASIC_AUTH_PASS |
static String |
PROP_BASIC_AUTH_USER |
static String |
PROP_CONNECTION_TIMEOUT |
static String |
PROP_FOLLOW_REDIRECTS |
static String |
PROP_MAX_CONNECTIONS |
static String |
PROP_MAX_CONNECTIONS_PER_HOST |
static String |
PROP_SO_TIMEOUT |
static String |
PROP_USE_RETRY |
static String |
SYS_PROP_CHECK_PEER_NAME |
Constructor and Description |
---|
HttpClientUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addRequestInterceptor(org.apache.http.HttpRequestInterceptor interceptor) |
static void |
close(org.apache.http.client.HttpClient httpClient) |
static void |
configureClient(org.apache.http.impl.client.DefaultHttpClient httpClient,
SolrParams config)
Configures
DefaultHttpClient , only sets parameters if they are
present in config. |
static org.apache.http.impl.client.CloseableHttpClient |
createClient(SolrParams params)
Creates new http client by using the provided configuration.
|
static org.apache.http.impl.client.CloseableHttpClient |
createClient(SolrParams params,
org.apache.http.conn.ClientConnectionManager cm)
Creates new http client by using the provided configuration.
|
static HttpClientConfigurer |
getConfigurer() |
static void |
removeRequestInterceptor(org.apache.http.HttpRequestInterceptor interceptor) |
static void |
setAllowCompression(org.apache.http.impl.client.DefaultHttpClient httpClient,
boolean allowCompression)
Control HTTP payload compression.
|
static void |
setBasicAuth(org.apache.http.impl.client.DefaultHttpClient httpClient,
String basicAuthUser,
String basicAuthPass)
Set http basic auth information.
|
static void |
setConfigurer(HttpClientConfigurer newConfigurer)
Replace the
HttpClientConfigurer class used in configuring the http
clients with a custom implementation. |
static void |
setConnectionTimeout(org.apache.http.client.HttpClient httpClient,
int timeout)
Set connection timeout.
|
static void |
setFollowRedirects(org.apache.http.client.HttpClient httpClient,
boolean followRedirects)
Set follow redirects.
|
static void |
setHostNameVerifier(org.apache.http.impl.client.DefaultHttpClient httpClient,
org.apache.http.conn.ssl.X509HostnameVerifier hostNameVerifier) |
static void |
setMaxConnections(org.apache.http.client.HttpClient httpClient,
int max)
Set max total connections allowed.
|
static void |
setMaxConnectionsPerHost(org.apache.http.client.HttpClient httpClient,
int max)
Set max connections allowed per host.
|
static void |
setSoTimeout(org.apache.http.client.HttpClient httpClient,
int timeout)
Defines the socket timeout (SO_TIMEOUT) in milliseconds.
|
static void |
setStaleCheckingEnabled(org.apache.http.client.HttpClient httpClient,
boolean enabled) |
static void |
setTcpNoDelay(org.apache.http.client.HttpClient httpClient,
boolean tcpNoDelay) |
static void |
setUseRetry(org.apache.http.impl.client.DefaultHttpClient httpClient,
boolean useRetry)
Control retry handler
|
public static final String PROP_SO_TIMEOUT
public static final String PROP_CONNECTION_TIMEOUT
public static final String PROP_MAX_CONNECTIONS_PER_HOST
public static final String PROP_MAX_CONNECTIONS
public static final String PROP_USE_RETRY
public static final String PROP_ALLOW_COMPRESSION
public static final String PROP_FOLLOW_REDIRECTS
public static final String PROP_BASIC_AUTH_USER
public static final String PROP_BASIC_AUTH_PASS
public static final String SYS_PROP_CHECK_PEER_NAME
public static void setConfigurer(HttpClientConfigurer newConfigurer)
HttpClientConfigurer
class used in configuring the http
clients with a custom implementation.public static HttpClientConfigurer getConfigurer()
public static org.apache.http.impl.client.CloseableHttpClient createClient(SolrParams params)
params
- http client configuration, if null a client with default
configuration (no additional configuration) is created.public static org.apache.http.impl.client.CloseableHttpClient createClient(SolrParams params, org.apache.http.conn.ClientConnectionManager cm)
public static void configureClient(org.apache.http.impl.client.DefaultHttpClient httpClient, SolrParams config)
DefaultHttpClient
, only sets parameters if they are
present in config.public static void close(org.apache.http.client.HttpClient httpClient)
public static void addRequestInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
public static void removeRequestInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
public static void setAllowCompression(org.apache.http.impl.client.DefaultHttpClient httpClient, boolean allowCompression)
allowCompression
- true will enable compression (needs support from server), false
will disable compression.public static void setBasicAuth(org.apache.http.impl.client.DefaultHttpClient httpClient, String basicAuthUser, String basicAuthPass)
public static void setMaxConnectionsPerHost(org.apache.http.client.HttpClient httpClient, int max)
ThreadSafeClientConnManager
or
PoolingClientConnectionManager
is used.public static void setMaxConnections(org.apache.http.client.HttpClient httpClient, int max)
ThreadSafeClientConnManager
or
PoolingClientConnectionManager
is used.public static void setSoTimeout(org.apache.http.client.HttpClient httpClient, int timeout)
timeout
- timeout in millisecondspublic static void setUseRetry(org.apache.http.impl.client.DefaultHttpClient httpClient, boolean useRetry)
useRetry
- when false the client will not try to retry failed requests.public static void setConnectionTimeout(org.apache.http.client.HttpClient httpClient, int timeout)
timeout
- connection Timeout in millisecondspublic static void setFollowRedirects(org.apache.http.client.HttpClient httpClient, boolean followRedirects)
followRedirects
- When true the client will follow redirects.public static void setHostNameVerifier(org.apache.http.impl.client.DefaultHttpClient httpClient, org.apache.http.conn.ssl.X509HostnameVerifier hostNameVerifier)
public static void setStaleCheckingEnabled(org.apache.http.client.HttpClient httpClient, boolean enabled)
public static void setTcpNoDelay(org.apache.http.client.HttpClient httpClient, boolean tcpNoDelay)
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.