HttpClient Authentication Doument:
http://hc.apache.org/httpclient-3.x/authentication.html
HttpClient支持使用代理服務器以及身份認證
1、代理服務器的設置很簡單:
HttpClient client = new HttpClient();
client.getHostConfiguration().setProxy(host, port);
2、身份驗證:
HttpClient client = new HttpClient();
client.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials("username", "password");
client.getState().setCredentials(AuthScope.ANY, defaultcreds);