Class HttpClientUtil
- java.lang.Object
-
- org.apache.solr.client.solrj.impl.HttpClientUtil
-
public class HttpClientUtil extends Object
Utility class for creating/configuring httpclient instances. This class can touch internal HttpClient details and is subject to change.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpClientUtil.SchemaRegistryProvider
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CONNECT_TIMEOUT
static int
DEFAULT_MAXCONNECTIONS
static int
DEFAULT_MAXCONNECTIONSPERHOST
static int
DEFAULT_SO_TIMEOUT
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
System property consulted to determine if the defaultHttpClientUtil.SchemaRegistryProvider
will require hostname validation of SSL Certificates.static String
SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY
A Java system property to select the HttpClientBuilderFactory used for configuring the HttpClientBuilder instance by default.
-
Constructor Summary
Constructors Constructor Description HttpClientUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addRequestInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
static void
clearRequestInterceptors()
static void
close(org.apache.http.client.HttpClient httpClient)
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.impl.conn.PoolingHttpClientConnectionManager cm)
static org.apache.http.impl.client.CloseableHttpClient
createClient(SolrParams params, org.apache.http.impl.conn.PoolingHttpClientConnectionManager cm, boolean sharedConnectionManager)
Creates new http client by using the provided configuration.static org.apache.http.impl.client.CloseableHttpClient
createClient(SolrParams params, org.apache.http.impl.conn.PoolingHttpClientConnectionManager cm, boolean sharedConnectionManager, org.apache.http.protocol.HttpRequestExecutor httpRequestExecutor)
static org.apache.http.client.config.RequestConfig.Builder
createDefaultRequestConfigBuilder()
static org.apache.http.client.protocol.HttpClientContext
createNewHttpClientRequestContext()
Create a HttpClientContext object andHttpClientContext.setUserToken(Object)
to an internal singleton.static SolrHttpClientBuilder
getHttpClientBuilder()
static HttpClientUtil.SchemaRegistryProvider
getSchemaRegisteryProvider()
static void
removeRequestInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
static void
resetHttpClientBuilder()
static void
setCookiePolicy(String policyName)
static void
setHttpClientBuilder(SolrHttpClientBuilder newHttpClientBuilder)
static void
setHttpClientProvider(SolrHttpClientBuilder newHttpClientBuilder)
static void
setHttpClientRequestContextBuilder(SolrHttpClientContextBuilder httpClientContextBuilder)
static void
setSchemaRegistryProvider(HttpClientUtil.SchemaRegistryProvider newRegistryProvider)
-
-
-
Field Detail
-
DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_SO_TIMEOUT
public static final int DEFAULT_SO_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_MAXCONNECTIONSPERHOST
public static final int DEFAULT_MAXCONNECTIONSPERHOST
- See Also:
- Constant Field Values
-
DEFAULT_MAXCONNECTIONS
public static final int DEFAULT_MAXCONNECTIONS
- See Also:
- Constant Field Values
-
PROP_MAX_CONNECTIONS_PER_HOST
public static final String PROP_MAX_CONNECTIONS_PER_HOST
- See Also:
- Constant Field Values
-
PROP_MAX_CONNECTIONS
public static final String PROP_MAX_CONNECTIONS
- See Also:
- Constant Field Values
-
PROP_USE_RETRY
public static final String PROP_USE_RETRY
- See Also:
- Constant Field Values
-
PROP_ALLOW_COMPRESSION
public static final String PROP_ALLOW_COMPRESSION
- See Also:
- Constant Field Values
-
PROP_BASIC_AUTH_USER
public static final String PROP_BASIC_AUTH_USER
- See Also:
- Constant Field Values
-
PROP_BASIC_AUTH_PASS
public static final String PROP_BASIC_AUTH_PASS
- See Also:
- Constant Field Values
-
SYS_PROP_CHECK_PEER_NAME
public static final String SYS_PROP_CHECK_PEER_NAME
System property consulted to determine if the defaultHttpClientUtil.SchemaRegistryProvider
will require hostname validation of SSL Certificates. The default behavior is to enforce peer name validation.This property will have no effect if
setSchemaRegistryProvider(org.apache.solr.client.solrj.impl.HttpClientUtil.SchemaRegistryProvider)
is used to override the defaultHttpClientUtil.SchemaRegistryProvider
- See Also:
- Constant Field Values
-
PROP_FOLLOW_REDIRECTS
public static final String PROP_FOLLOW_REDIRECTS
- See Also:
- Constant Field Values
-
PROP_SO_TIMEOUT
public static final String PROP_SO_TIMEOUT
- See Also:
- Constant Field Values
-
PROP_CONNECTION_TIMEOUT
public static final String PROP_CONNECTION_TIMEOUT
- See Also:
- Constant Field Values
-
SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY
public static final String SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY
A Java system property to select the HttpClientBuilderFactory used for configuring the HttpClientBuilder instance by default.- See Also:
- Constant Field Values
-
-
Method Detail
-
setHttpClientBuilder
public static void setHttpClientBuilder(SolrHttpClientBuilder newHttpClientBuilder)
-
setHttpClientProvider
public static void setHttpClientProvider(SolrHttpClientBuilder newHttpClientBuilder)
-
setSchemaRegistryProvider
public static void setSchemaRegistryProvider(HttpClientUtil.SchemaRegistryProvider newRegistryProvider)
- See Also:
SYS_PROP_CHECK_PEER_NAME
-
getHttpClientBuilder
public static SolrHttpClientBuilder getHttpClientBuilder()
-
getSchemaRegisteryProvider
public static HttpClientUtil.SchemaRegistryProvider getSchemaRegisteryProvider()
- See Also:
SYS_PROP_CHECK_PEER_NAME
-
resetHttpClientBuilder
public static void resetHttpClientBuilder()
-
createClient
public static org.apache.http.impl.client.CloseableHttpClient createClient(SolrParams params)
Creates new http client by using the provided configuration.- Parameters:
params
- http client configuration, if null a client with default configuration (no additional configuration) is created.
-
createClient
public static org.apache.http.impl.client.CloseableHttpClient createClient(SolrParams params, org.apache.http.impl.conn.PoolingHttpClientConnectionManager cm)
-
createClient
public static org.apache.http.impl.client.CloseableHttpClient createClient(SolrParams params, org.apache.http.impl.conn.PoolingHttpClientConnectionManager cm, boolean sharedConnectionManager, org.apache.http.protocol.HttpRequestExecutor httpRequestExecutor)
-
createClient
public static org.apache.http.impl.client.CloseableHttpClient createClient(SolrParams params, org.apache.http.impl.conn.PoolingHttpClientConnectionManager cm, boolean sharedConnectionManager)
Creates new http client by using the provided configuration.
-
close
public static void close(org.apache.http.client.HttpClient httpClient)
-
addRequestInterceptor
public static void addRequestInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
-
removeRequestInterceptor
public static void removeRequestInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
-
clearRequestInterceptors
public static void clearRequestInterceptors()
-
setHttpClientRequestContextBuilder
public static void setHttpClientRequestContextBuilder(SolrHttpClientContextBuilder httpClientContextBuilder)
-
createNewHttpClientRequestContext
public static org.apache.http.client.protocol.HttpClientContext createNewHttpClientRequestContext()
Create a HttpClientContext object andHttpClientContext.setUserToken(Object)
to an internal singleton. It allows to reuse underneathHttpClient
in connection pools if client authentication is enabled.
-
createDefaultRequestConfigBuilder
public static org.apache.http.client.config.RequestConfig.Builder createDefaultRequestConfigBuilder()
-
setCookiePolicy
public static void setCookiePolicy(String policyName)
-
-