参数介绍
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(5000)
.setConnectTimeout(5000)
.setSocketTimeout(5000)
.build();
如何使用?
CloseableHttpClient httpClient = HttpClients.custom()
.setMaxConnTotal(10)
.setMaxConnPerRoute(5)
.build();
HttpGet httpGet = new HttpGet("http://www.example.com");
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(5000)
.build();
httpGet.setConfig(requestConfig);
CloseableHttpResponse response = httpClient.execute(httpGet);
参考:http RequestConfig配置类中各参数的意思