Showing posts with label client. Show all posts
Showing posts with label client. Show all posts

Tuesday, May 4, 2010

how to use proxy with Apache HttpClient?

Small pin.

public static connect() {

    // some code ...

    HttpClient client = new HttpClient();

    client.getHostConfiguration().setProxy(
        "PROXY-SERVER",
        proxyPort);

    client.getState().setProxyCredentials(
        AuthScope.ANY,
        new UsernamePasswordCredentials("USERNAME", "PASSWORD"));

    // some code ...

}
highlighted with: http://tohtml.com/