Example usage for org.apache.commons.httpclient ProxyClient getParams

List of usage examples for org.apache.commons.httpclient ProxyClient getParams

Introduction

In this page you can find the example usage for org.apache.commons.httpclient ProxyClient getParams.

Prototype

public HttpClientParams getParams()

Source Link

Usage

From source file:ConnectMethodExampleForProxyClient.java

public static void main(String args[]) {

    ProxyClient client = new ProxyClient();
    client.getParams().setParameter("http.useragent", "Proxy Test Client");

    client.getHostConfiguration().setHost("www.somehost.com");
    client.getHostConfiguration().setProxy("localproxyaddress", 80);

    Socket socket = null;/*from   ww  w.ja  v a2 s. c  o  m*/

    try {
        ConnectResponse response = client.connect();
        socket = response.getSocket();
        if (socket == null) {
            ConnectMethod method = response.getConnectMethod();
            System.err.println("Socket not created: " + method.getStatusLine());
        }
        // do something
    } catch (Exception e) {
        System.err.println(e);
    } finally {
        if (socket != null)
            try {
                socket.close();
            } catch (Exception fe) {
            }
    }

}