On Tue, 2015-08-04 at 11:42 -0700, Check Peck wrote:
> I am using Apache HttpClient 4.2.5 which is very old and we cannot update
> as of now due to old legacy system we have. In my other project in which I
> am using Apache HttpClient 4.3.1, I am using below code:
> 
>     private ClientHttpRequestFactory clientHttpRequestFactory() {
>         HttpComponentsClientHttpRequestFactory requestFactory = new
> HttpComponentsClientHttpRequestFactory();
>         RequestConfig requestConfig =
> RequestConfig.custom().setConnectionRequestTimeout(1000).setConnectTimeout(1000)
> 
> .setSocketTimeout(1000).setStaleConnectionCheckEnabled(false).build();
>         SocketConfig socketConfig =
> SocketConfig.custom().setSoKeepAlive(true).setTcpNoDelay(true).build();
> 
>         PoolingHttpClientConnectionManager
> poolingHttpClientConnectionManager = new
> PoolingHttpClientConnectionManager();
>         poolingHttpClientConnectionManager.setMaxTotal(300);
>         poolingHttpClientConnectionManager.setDefaultMaxPerRoute(200);
> 
>         CloseableHttpClient httpClientBuilder = HttpClientBuilder.create()
> 
> .setConnectionManager(poolingHttpClientConnectionManager).setDefaultRequestConfig(requestConfig)
>                 .setDefaultSocketConfig(socketConfig).build();
> 
>         requestFactory.setHttpClient(httpClientBuilder);
>         return requestFactory;
>     }
> 
> I cannot use same above code in my legacy code in which I have 4.2.5 Apache
> HttpClient. I cannot find RequestConfig and SocketConfig. Is there any
> other way to achieve the above thing in 4.2.5 Apache HttpClient?

Yes, there is. You have to use older HttpParams APIs

https://hc.apache.org/httpcomponents-core-4.2.x/httpcore/apidocs/org/apache/http/params/HttpConnectionParams.html

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to