Hello, I'm using the 4.3.x "fluent API" of HTTP client. I'd like to be able to change the socket timeout and the connect timeout at runtime without having to shutdown an active HTTP client and its associated pooling connection manager (because that would likely cause a brief period of unavailability adding further complexity to calling code, or failure). Here's a (simplified) bit of code showing how I set it up at first.
final HttpClientBuilder builder = HttpClients.custom().useSystemProperties() .disableAuthCaching() .disableAutomaticRetries() .disableContentCompression() .disableCookieManagement() .disableRedirectHandling(); if (highCapacity) { _pool = new PoolingHttpClientConnectionManager(); doSetNetworkPoolSize(_ps.getNetworkPoolSize(), _pool); builder.setConnectionManager(_pool); } else { _pool = null; builder.setConnectionManager(new BasicHttpClientConnectionManager()); } builder.*setDefaultRequestConfig*(RequestConfig.custom() .setAuthenticationEnabled(false) .setCookieSpec(CookieSpecs.IGNORE_COOKIES) .setRedirectsEnabled(false) .*setSocketTimeout(SOCKET_TIMEOUT)* .*setConnectTimeout(CONNECTION_TIMEOUT)* .build() ); _http = builder.build(); The JavaDoc for "*setDefaultRequestConfig*" states: *Assigns default RequestConfig instance which will be used for request execution if not explicitly set in the client execution context.* ...but doesn't go as far as indicating how to explicitly set in the client execution context. I currently execute requests via: CloseableHttpClient.execute(HttpUriRequest) ...so I assumed that this meant I should instead use: CloseableHttpClient.execute(HttpUriRequest,HttpContext) ...but *HttpContext* is a very generic interface, and (assuming that's what I'm supposed to be using), I can't see how to create or obtain an instance that might override just these specific properties without clobbering anything else unintentionally. What is the intended way to override (per request, or for all subsequent requests) the socket timeout and the connect timeout? Thanks in advance. Christopher