3
看来我可以指定代理,当我建立新HttpClient
有:的Apache的HttpClient 4.3.5设置代理
HttpHost proxy = new HttpHost("someproxy", 8080);
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
CloseableHttpClient httpclient = HttpClients.custom()
.setRoutePlanner(routePlanner)
.build();
从http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d5e475
考虑是否有可能修改现有客户端的代理设置。
哦使用DynamicProxyRoutePlanner,这是显而易见的。无论如何,Thx!我如何设置不使用代理? – 2014-08-29 14:34:44
可能只是修改DynamicProxyRoutePlanner.determineRoute方法。如果defaultProxyRoutePlanner字段将设置为空,我会使用org.apache.http.impl.conn.DefaultRoutePlanner(使用DefaultSchemePortResolver.INSTANCE构造它) – 2014-08-29 14:55:36