public class HttpUtils extends Object
http://www.browserscope.org/?category=network
,
Modifier and Type | Field and Description |
---|---|
static int |
CACHE_MAX_ENTRIES |
static int |
CACHE_MAX_OBJECT_SIZE |
static long |
DEFAULT_KEEP_ALIVE_SECONDS |
static int |
MAX_CONNECTIONS
The maximum number of connections allowed in total by the HttpClient
|
static int |
MAX_CONNECTIONS_PER_ROUTE
The number of parallel connections allowed per route / server
Use caution resetting this one: more is not better:
|
static boolean |
MONITOR_STALE_CONNECTIONS |
static String |
SCHEME_NAME |
static boolean |
USE_CACHING_CLIENT |
Constructor and Description |
---|
HttpUtils() |
Modifier and Type | Method and Description |
---|---|
static org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> |
buildConnectionRegistry() |
static org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> |
buildConnectionRegistry(X509Session x509Session) |
static org.apache.http.conn.ConnectionKeepAliveStrategy |
buildD1KeepAliveStrategy(long defaultKeepAliveTimeout)
Builds a custom keep-alive strategy that uses the defaultKeepAliveTimeout
value if one not returned in the response headers.
|
static org.apache.http.client.HttpClient |
createHttpClient(String authToken)
Creates an HttpClient configured with the authorization token credentials.
|
static org.apache.http.client.HttpClient |
createHttpClient(X509Session x509session)
Creates an HttpClient configured with the X509 credentials.
|
static org.apache.http.impl.client.HttpClientBuilder |
getHttpClientBuilder(String authToken)
Returns an HttpClientBuilder with the DataONE-standard ConnectionManager configuration specified.
|
static org.apache.http.impl.client.HttpClientBuilder |
getHttpClientBuilder(String authToken,
Boolean monitorStaleConnections)
Returns an HttpClientBuilder with the DataONE-standard ConnectionManager configuration specified.
|
static org.apache.http.impl.client.HttpClientBuilder |
getHttpClientBuilder(X509Session x509session)
Returns an HttpClientBuilder with the DataONE-standard ConnectionManager configuration
specified.
|
static org.apache.http.impl.client.HttpClientBuilder |
getHttpClientBuilder(X509Session x509session,
Boolean monitorStaleConnections)
Returns an HttpClientBuilder with the DataONE-standard ConnectionManager configuration
specified.
|
static X509Session |
selectSession(String subjectString) |
static void |
setupSSL_v4_1(org.apache.http.impl.client.AbstractHttpClient httpClient,
X509Session x509Session)
Provided to assist with backwards compatibility with v4.1.x era DefaultHttpClient
(now deprecated).
|
public static final String SCHEME_NAME
public static final boolean MONITOR_STALE_CONNECTIONS
public static final int MAX_CONNECTIONS
public static final int MAX_CONNECTIONS_PER_ROUTE
https://redmine.dataone.org/issues/7463#note-1
public static final long DEFAULT_KEEP_ALIVE_SECONDS
public static final boolean USE_CACHING_CLIENT
public static final int CACHE_MAX_ENTRIES
public static final int CACHE_MAX_OBJECT_SIZE
public static void setupSSL_v4_1(org.apache.http.impl.client.AbstractHttpClient httpClient, X509Session x509Session)
session
- public static org.apache.http.client.HttpClient createHttpClient(X509Session x509session) throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException, InstantiationException, IllegalAccessException, IOException, MarshallingException
x509session
- - - the configuration object containing the X509 client certificate used for the connectionsUnrecoverableKeyException
KeyManagementException
NoSuchAlgorithmException
KeyStoreException
CertificateException
InstantiationException
IllegalAccessException
IOException
MarshallingException
public static org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder(X509Session x509session) throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException, InstantiationException, IllegalAccessException, IOException, MarshallingException
x509session
- - the configuration object containing the X509 client certificate used for the connectionsUnrecoverableKeyException
KeyManagementException
NoSuchAlgorithmException
KeyStoreException
CertificateException
InstantiationException
IllegalAccessException
IOException
MarshallingException
public static org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder(X509Session x509session, Boolean monitorStaleConnections) throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException, InstantiationException, IllegalAccessException, IOException, MarshallingException
x509session
- - the configuration object containing the X509 client certificate used for the connectionsmonitorStaleConnections
- - if not null chooses whether or not to monitorStaleConnections, otherwise uses
the default setting determined from D1Client.http.monitorStaleConnectionsUnrecoverableKeyException
KeyManagementException
NoSuchAlgorithmException
KeyStoreException
CertificateException
InstantiationException
IllegalAccessException
IOException
MarshallingException
public static org.apache.http.client.HttpClient createHttpClient(String authToken)
authToken
- - the configuration object containing the authorization token string used for the connectionspublic static org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder(String authToken)
authToken
- - the configuration object containing the authorization token string used for the connectionspublic static org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder(String authToken, Boolean monitorStaleConnections)
authToken
- - the configuration object containing the authorization token string used for the connectionsmonitorStaleConnections
- - if not null, choose whether to monitor stale connections, otherwise
use the configured default in D1Client.http.monitorStaleConnectionspublic static X509Session selectSession(String subjectString) throws IOException
IOException
public static org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> buildConnectionRegistry(X509Session x509Session) throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
public static org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> buildConnectionRegistry()
public static org.apache.http.conn.ConnectionKeepAliveStrategy buildD1KeepAliveStrategy(long defaultKeepAliveTimeout)
defaultKeepAliveTimeout
- - number of seconds (to match units of the keep-alive timeout header)Copyright © 2020. All Rights Reserved.