Can some one guide me how can I configure HttpComponentsClientHttpRequestFactory
to use proxy server.
All examples I have seen are using SimpleClientHttpRequestFactory
.
Can some one guide me how can I configure HttpComponentsClientHttpRequestFactory
to use proxy server.
All examples I have seen are using SimpleClientHttpRequestFactory
.
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:
That way, it even regards the nonProxyHosts setting.
If you do not mind using Apache Http Client it is not very complicated and there are 2 possibilities:
If single proxy for all targets is enough for you:
Or if you want to use different proxies for different target URIs, schemas, etc. you can use
HttpRoutePlanner
with customProxySelector
:Example proxy selector:
MyProxySelector.java
: