use of org.wikimedia.utils.http.CustomRoutePlanner in project wikidata-query-rdf by wikimedia.
the class HttpClientUtils method configureHttpClient.
public static HttpClientBuilder configureHttpClient(HttpClientBuilder httpClientBuilder, HttpClientConnectionManager connectionManager, String proxy, String proxyMapString, int requestTimeout, String userAgent) {
if (proxy != null && proxyMapString != null) {
throw new IllegalArgumentException("Cannot set both proxy and proxy map property");
}
httpClientBuilder.setConnectionManager(connectionManager).setRetryHandler(getRetryHandler(RETRIES)).setServiceUnavailableRetryStrategy(getRetryStrategy(RETRIES, RETRY_INTERVAL)).disableCookieManagement().setUserAgent(userAgent).setDefaultRequestConfig(RequestConfig.custom().setSocketTimeout(requestTimeout).setConnectTimeout(requestTimeout).setConnectionRequestTimeout(requestTimeout).build());
if (proxyMapString != null) {
Map<String, HttpHost> proxyMap = createProxyMap(proxyMapString);
httpClientBuilder.setRoutePlanner(new CustomRoutePlanner(proxyMap, new DefaultRoutePlanner(DefaultSchemePortResolver.INSTANCE)));
}
if (proxy != null) {
HttpHost httpHost = HttpHost.create(proxy);
httpClientBuilder.setProxy(httpHost);
}
return httpClientBuilder;
}
Aggregations