public class HttpClientUtil extends Object
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 |
Modifier and Type | Method and Description |
---|---|
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.client.HttpClient |
createClient(SolrParams params)
Creates new http client by using the provided configuration.
|
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 |
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 |
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 void setConfigurer(HttpClientConfigurer newConfigurer)
HttpClientConfigurer
class used in configuring the http
clients with a custom implementation.public static org.apache.http.client.HttpClient createClient(SolrParams params)
params
- http client configuration, if null a client with default
configuration (no additional configuration) is created.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 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.Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.