I want to set proxy before sending HttpClient request on a URL. As I am able to connect it curl command setting up the proxy but with Java code I am not able to
System properties usually have to be set right upfront, which means either in the jvm startup with
-Dhttp.proxyHost=some.host.com
-Dhttp.proxyPort=8080, not forgetting the httpsProxyHost and ...Port)
Or which should work, too, in a static {} block.
I personally find the Jersey client implementation easier to work with, if you have the option to switch.