Can some one guide me how can I configure HttpComponentsClientHttpRequestFactory
to use proxy server.
All examples I have seen are using SimpleClientH
Very simple way to let the HttpComponentsClientHttpRequestFactory use the standard java SystemProperties for proxy-stuff (see https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html)
is this:
HttpRoutePlanner routePlanner = new SystemDefaultRoutePlanner(ProxySelector.getDefault());
HttpClient httpClient = HttpClientBuilder
.create()
.setRoutePlanner(routePlanner)
.build();
restTemplate.setRequestFactory(
new HttpComponentsClientHttpRequestFactory(httpClient));
That way, it even regards the nonProxyHosts setting.