HttpClient 4的代理设置方法:
CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(<proxy-host>, <proxy-port>), new UsernamePasswordCredentials(<proxy-username>, <proxy-password>)); httpClient.setCredentialsProvider(credsProvider); HttpHost proxy = new HttpHost(<proxy-host>, <proxy-port>, "http"); httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
新版本中已经不使用这种方式,待更新。