public static HttpClientAndConnectionManager initHttpConnection(final AWSRequestAuthorizer awsRequestAuthorizer,
HostConfiguration hostConfig, Jets3tProperties jets3tProperties, String userAgentDescription,
CredentialsProvider credentialsProvider)
{
// Configure HttpClient properties based on Jets3t Properties.
HttpConnectionManagerParams connectionParams = new HttpConnectionManagerParams();
connectionParams.setConnectionTimeout(jets3tProperties.
getIntProperty("httpclient.connection-timeout-ms", 60000));
connectionParams.setSoTimeout(jets3tProperties.
getIntProperty("httpclient.socket-timeout-ms", 60000));
connectionParams.setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION,
jets3tProperties.getIntProperty("httpclient.max-connections", 4));
connectionParams.setStaleCheckingEnabled(jets3tProperties.
getBoolProperty("httpclient.stale-checking-enabled", true));
// Connection properties to take advantage of S3 window scaling.
if (jets3tProperties.containsKey("httpclient.socket-receive-buffer")) {
connectionParams.setReceiveBufferSize(jets3tProperties.
getIntProperty("httpclient.socket-receive-buffer", 0));
}
if (jets3tProperties.containsKey("httpclient.socket-send-buffer")) {
connectionParams.setSendBufferSize(jets3tProperties.
getIntProperty("httpclient.socket-send-buffer", 0));
}
connectionParams.setTcpNoDelay(true);
MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
connectionManager.setParams(connectionParams);
// Set user agent string.