Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.ProxyClient


*/
public class ProxyTunnelDemo {

    public static void main(String[] args) throws Exception {
       
        ProxyClient proxyclient = new ProxyClient();
        // set the host the proxy should create a connection to
        //
        // Note:  By default port 80 will be used. Some proxies only allow conections
        // to ports 443 and 8443.  This is because the HTTP CONNECT method was intented
        // to be used for tunneling HTTPS.
        proxyclient.getHostConfiguration().setHost("www.yahoo.com");
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
        // set the proxy credentials, only necessary for authenticating proxies
        proxyclient.getState().setProxyCredentials(
            new AuthScope("10.0.1.1", 3128, null),
            new UsernamePasswordCredentials("proxy", "proxy"));
       
        // create the socket
        ProxyClient.ConnectResponse response = proxyclient.connect();
       
        if (response.getSocket() != null) {
            Socket socket = response.getSocket();
            try {
                // go ahead and do an HTTP GET using the socket
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.ProxyClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.