Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,18 @@ private void initializeHttpClient() {
}

private void initializeHttpPoolingClient() {
Registry<ConnectionSocketFactory> registry = createConnectionSocketFactoryRegistry();
PoolingHttpClientConnectionManager httpConnectionManager = new PoolingHttpClientConnectionManager(registry);
httpConnectionManager.setMaxTotal(maximumPoolingConnections);
httpConnectionManager.setDefaultMaxPerRoute(maximumPoolingConnections);
AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy();

httpPoolingClient = HttpClients.custom()
.setConnectionManager(httpConnectionManager)
.setTargetAuthenticationStrategy(authStrategy)
.build();
}


Registry<ConnectionSocketFactory> registry = createConnectionSocketFactoryRegistry();
PoolingHttpClientConnectionManager httpConnectionManager = new PoolingHttpClientConnectionManager(registry);
httpConnectionManager.setMaxTotal(maximumPoolingConnections);
httpConnectionManager.setDefaultMaxPerRoute(maximumPoolingConnections);
AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy();

httpPoolingClient = HttpClients.custom()
.setConnectionManager(httpConnectionManager)
.setTargetAuthenticationStrategy(authStrategy)
.build();
}

/**
* Sets the maximum number of connections for the pooling connection manager which is used for
* subscriptions.
Expand Down Expand Up @@ -344,26 +343,27 @@ protected HttpWebRequest prepareHttpWebRequestForUrl(URI url, boolean acceptGzip
* @throws java.net.URISyntaxException the uRI syntax exception
*/
protected HttpWebRequest prepareHttpPoolingWebRequestForUrl(URI url, boolean acceptGzipEncoding,
boolean allowAutoRedirect) throws ServiceLocalException, URISyntaxException {
// Verify that the protocol is something that we can handle
String scheme = url.getScheme();
if (!scheme.equalsIgnoreCase(EWSConstants.HTTP_SCHEME)
&& !scheme.equalsIgnoreCase(EWSConstants.HTTPS_SCHEME)) {
String strErr = String.format("Protocol %s isn't supported for service request.", scheme);
throw new ServiceLocalException(strErr);
}

if (httpPoolingClient == null)
initializeHttpPoolingClient();
HttpClientWebRequest request = new HttpClientWebRequest(httpPoolingClient, httpContext);
prepareHttpWebRequestForUrl(url, acceptGzipEncoding, allowAutoRedirect, request);

return request;
}

private void prepareHttpWebRequestForUrl(URI url, boolean acceptGzipEncoding, boolean allowAutoRedirect, HttpClientWebRequest request)
throws ServiceLocalException, URISyntaxException
{
boolean allowAutoRedirect) throws ServiceLocalException, URISyntaxException {
// Verify that the protocol is something that we can handle
String scheme = url.getScheme();
if (!scheme.equalsIgnoreCase(EWSConstants.HTTP_SCHEME)
&& !scheme.equalsIgnoreCase(EWSConstants.HTTPS_SCHEME)) {
String strErr = String.format("Protocol %s isn't supported for service request.", scheme);
throw new ServiceLocalException(strErr);
}

if (httpPoolingClient == null) {
initializeHttpPoolingClient();
}

HttpClientWebRequest request = new HttpClientWebRequest(httpPoolingClient, httpContext);
prepareHttpWebRequestForUrl(url, acceptGzipEncoding, allowAutoRedirect, request);

return request;
}

private void prepareHttpWebRequestForUrl(URI url, boolean acceptGzipEncoding, boolean allowAutoRedirect,
HttpClientWebRequest request) throws ServiceLocalException, URISyntaxException {
try {
request.setUrl(url.toURL());
} catch (MalformedURLException e) {
Expand Down