HC4 allows one to provide a ConnectionKeepAliveStrategy which allows one to provide a time-to-live (TTL) for the connection, based on the HttpResponse and the HttpContext
There is a default implementation which uses the Keep-Alive header to calculate the time. So we can subclass that, and provide our own calculation if the default one does not find the header. That's easy, and I've tried it. What is not so obvious is how to specify which URLs need what idle timeouts. The simplest would be to use a property to apply a timeout to any requests that don't return the Keep-Alive header, but that may be too crude in general, as it would enforce timeouts on every host. However it would be a good proof of concept that could be used against S3 etc. We could add an idle timeout field to the HttpSampler GUIbut that might be tedious to maintain. Adding it to the Http Defaults would work provided that there was a single value that suited all the Http requests in scope (not much better than using a global property). Would that be sufficient? Or do we need a way to specify the timeout on a per-host basis? Maybe a list of hostnames and timeouts? Any other bright ideas? I propose to implement the single property method (but document it as subject to change) so that it can be tested in earnest. Then we can see how it might need to be extended.
