在一个测试,我做的:何时HttpUrlConnection.usingProxy()返回true?
System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "1080");
,然后打开一个连接:
connection = (HttpURLConnection)url.openConnection();
if (connection.usingProxy()) {
throw new Nope();
}
正在使用的代理服务器,否则连接会失败。但usingProxy()
返回false。
我错过了什么?
对话是一个滑稽的灾难,它甚至不是准确的。选择器不会提出任何问题。它提供了参数。 – EJP
@EJP的确,作者提到他或她“稍微修饰一些”。我想突出说明在选择下一个代理之前访问代理的部分。 – manouti