String capabilitiesURL = info.getCapabilitiesURL();
// check for mock bindings. Since we are going to run this code in production as well,
// guard it so that it only triggers if the MockHttpClientProvider has any active binding
if(TestHttpClientProvider.testModeEnabled() && capabilitiesURL.startsWith(TestHttpClientProvider.MOCKSERVER)) {
HTTPClient client = TestHttpClientProvider.get(capabilitiesURL);
return client;
}
HTTPClient client;
if (info.isUseConnectionPooling()) {
client = new MultithreadedHttpClient();
if (info.getMaxConnections() > 0) {
int maxConnections = info.getMaxConnections();
MultithreadedHttpClient mtClient = (MultithreadedHttpClient) client;
mtClient.setMaxConnections(maxConnections);
}
} else {
client = new SimpleHttpClient();
}
String username = info.getUsername();
String password = info.getPassword();
int connectTimeout = info.getConnectTimeout();
int readTimeout = info.getReadTimeout();
client.setUser(username);
client.setPassword(password);
client.setConnectTimeout(connectTimeout);
client.setReadTimeout(readTimeout);
return client;
}