Hi. How can I set the SOCKS
proxy for a URLConnection
given by (new URL(url)).openConnection()
?
Different proxies are needed on a per-connection basis, so please don't suggest setting system properties.
Hi. How can I set the SOCKS
proxy for a URLConnection
given by (new URL(url)).openConnection()
?
Different proxies are needed on a per-connection basis, so please don't suggest setting system properties.
You can try commons-httpclient:
httpClient.getHostConfiguration().setProxy(proxyHost, proxyPort);
If you want to use different proxy settings on a per-connection bases, you can use the Java 6.0 ProxySelector
mechanism as described in Java Networking and Proxies. Specifically, read sections 3 and 4.