首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

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

2012-07-18 
HttpClient支持使用代理服务器以及身份认证HttpClient Authentication Doument:http://hc.apache.org/http

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

热点排行