|
// UsernamePasswordCredentials creds = new // UsernamePasswordCredentials("XXXXXX", "XXXXXX"); // 定义代理的ip和端口号 HostConfiguration hcf = new HostConfiguration(); hcf.setProxy("localhost", 8118); // 定义httpClient HttpClient httpClient = new HttpClient(); // 设置代理用户名密码 // httpClient.getState().setProxyCredentials(AuthScope.ANY, creds); // 设置代理地址端口 httpClient.setHostConfiguration(hcf); httpClient.getHttpConnectionManager().getParams().setConnectionTimeout( 3000000); httpClient.getHttpConnectionManager().getParams().setSoTimeout(3000000); return httpClient;
|
一共有 0 条评论