[英]How to use URLConnection through a SOCKS proxy?
How can I set the SOCKS
proxy for a URLConnection
given by (new URL(url)).openConnection()
? 如何为
(new URL(url)).openConnection()
给定的URLConnection
设置SOCKS
代理?
Different proxies are needed on a per-connection basis, so please don't suggest setting system properties. 每个连接需要不同的代理,因此请不要建议设置系统属性。
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 . 如果要在每个连接的基础上使用不同的代理设置,则可以使用Java Networking and Proxies中所述的Java 6.0
ProxySelector
机制。 Specifically, read sections 3 and 4. 具体来说,请阅读第3节和第4节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.