use of org.commonjava.util.jhttpc.JHttpCException in project galley by Commonjava.
the class HttpImpl method createClient.
@Override
public CloseableHttpClient createClient(final HttpLocation location) throws GalleyException {
try {
if (location != null) {
locationLookup.register(location);
int maxConnections = LocationUtils.getMaxConnections(location);
SiteConfigBuilder configBuilder = new SiteConfigBuilder(location.getName(), location.getUri());
configBuilder.withAttributes(location.getAttributes()).withKeyCertPem(location.getKeyCertPem()).withServerCertPem(location.getServerCertPem()).withProxyHost(location.getProxyHost()).withProxyPort(location.getProxyPort()).withProxyUser(location.getProxyUser()).withRequestTimeoutSeconds(LocationUtils.getTimeoutSeconds(location)).withUser(location.getUser()).withMaxConnections(maxConnections);
if (location.getTrustType() != null) {
configBuilder.withTrustType(SiteTrustType.getType(location.getTrustType().name()));
}
SiteConfig config = configBuilder.build();
return httpFactory.createClient(config);
} else {
return httpFactory.createClient();
}
} catch (JHttpCException e) {
throw new TransferLocationException(location, "Failed to initialize http client: %s", e, e.getMessage());
} finally {
}
}
Aggregations