HttpClient支持使用代理服务器以及身份认证


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); 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM