Get the diagnostics for proxy information.
ProxySelector selector = ProxySelector.getDefault();
List list = selector.select(destURI);
StringBuffer result = new StringBuffer();
Iterator proxies = list.listIterator();
while (proxies.hasNext()) {
Proxy proxy = (Proxy) proxies.next();
SocketAddress address = proxy.address();
if (address == null) {
result.append("Direct connection\n");
} else {
result.append(proxy.toString());
if (address instanceof InetSocketAddress) {
InetSocketAddress ina = (InetSocketAddress) address;
result.append(' ");
result.append(ina.getHostName());
result.append(':");
result.append(ina.getPort());
if (ina.isUnresolved()) {
result.append(" [unresolved]");
} else {
InetAddress addr = ina.getAddress();
result.append(" [");
result.append(addr.getHostAddress());
result.append(']");
}
}
result.append('\n");
}
}
return result.toString();