1
我发送HTTP请求在Apache的HttpClient的,我的代码是在这里:的HttpClient和连接超时
HttpHost proxy = new HttpHost("78.1.1.222", 80);
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
httpClient = HttpClients.custom()
.setRoutePlanner(routePlanner)
.build();
HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("Authorization","Basic " + encoding);
httpGet.addHeader("Cache-Control", "no-cache");
httpResponse = httpClient.execute(httpGet);
responseCode=httpResponse.getStatusLine().getStatusCode();
........
........(code continue..)
我的问题是,我怎么能连接超时时间添加到该代码? 请注意,我必须使用代理和我使用HttpClient 4.4。
您是否检查过Apache HttpClient文档?它有一个合适的方法吗? – RealSkeptic