I am trying to upgrade the HttpClient Dependency from 4.0.1 to 4.3.5. And was confused by setting the connection timeout in the new lib. For the following code:
HttpClient httpClient = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 300);
It will be replaced with the following code:
RequestConfig config = RequestConfig.custom().setConnectTimeout(300).build(); HttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
However, I'm not sure whether to use setConnectTimeout or setConnectionRequestTimeout , since I am not familiar with HttpClient. It seems to me that I should use setConnectionTimeout based on a java document in the source code. Can someone please confirm? Thanks in advance.
https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.3.3/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java
public int getConnectionRequestTimeout() { return connectionRequestTimeout; } public int getConnectTimeout() { return connectTimeout; }
source share