Code example for Proxy

Methods: address, type

0
     * Returns the target port of the socket connection; either a port of the 
     * origin server or an intermediate proxy. 
     */ 
    private int getConnectToPort() { 
        int hostPort = usingProxy()
                ? ((InetSocketAddress) proxy.address()).getPort()
                : url.getPort();
        return hostPort < 0 ? defaultPort : hostPort;
    } 
 
    /** 
     * Returns the target address of the socket connection; either the address 
     * of the origin server or an intermediate proxy. 
     */ 
    private InetAddress getConnectToInetAddress() throws IOException {
        return usingProxy() 
                ? ((InetSocketAddress) proxy.address()).getAddress()
                : InetAddress.getByName(url.getHost());
    } 
 
    /** 
     * Returns the target host name of the socket connection; either the host 
     * name of the origin server or an intermediate proxy. 
     */ 
    private String getConnectToHost() {
        return usingProxy() 
                ? ((InetSocketAddress) proxy.address()).getHostName()
                : url.getHost();
    } 
 
    private String getSystemProperty(final String property) {
        return AccessController.doPrivileged(new PriviAction<String>(property));
    } 
 
    @Override public final boolean usingProxy() { 
        return (proxy != null && proxy.type() != Proxy.Type.DIRECT);
    } 
 
    protected boolean requiresTunnel() { 
        return false; 
    }