Code example for Proxy

Methods: address, type

0
    } 
 
    public HttpConfiguration(URI uri, Proxy proxy) {
        this.uri = uri;
        this.proxy = proxy;
        if (proxy.type() == Proxy.Type.HTTP) {
            SocketAddress proxyAddr = proxy.address();
            if (!(proxyAddr instanceof InetSocketAddress)) {
               throw new IllegalArgumentException(Msg.getString(
                   "K0316", proxyAddr.getClass())); //$NON-NLS-1$
            } 
            InetSocketAddress iProxyAddr = (InetSocketAddress) proxyAddr;
            this.hostName = iProxyAddr.getHostName();
            this.hostPort = iProxyAddr.getPort();
        } else { 
            // using SOCKS proxy 
            this.hostName = uri.getHost();
            this.hostPort = uri.getPort();
            if(hostPort == -1) {
                if(uri.getScheme().equals("https")) { //$NON-NLS-1$
                    hostPort = 443;
                } else { 
                    hostPort = 80;
                } 
            } 
        } 
        this.uri = uri;
        SocketAddress proxyAddr = proxy.address();
        if (!(proxyAddr instanceof InetSocketAddress)) {
           throw new IllegalArgumentException(Msg.getString(
               "K0316", proxyAddr.getClass())); //$NON-NLS-1$
        } 
        InetSocketAddress iProxyAddr = (InetSocketAddress) proxyAddr;