Reputation: 17960
I'm using the Jetty HTTP Client and I want to force the client to close the connection to the server after a certain number of requests (regardless of their status) - this is basically an implementation of the "max" value for the HTTP Keep-Alive header.
Is this possible in Jetty? Digging through the docs there does not appear to be an option for it, and I can't find a place where I can get access to the connection that a request used and kill it after the request is done.
Upvotes: 0
Views: 600
Reputation: 49515
There is no such thing as a max
value for the Keep-Alive
header.
The Keep-Alive
header is a HTTP/1.0 only feature, and has no meaning outside of HTTP/1.0 (such as HTTP/1.1 or HTTP/2).
The Jetty HTTP Client is a HTTP/1.1 (and optionally a HTTP/2 client as well).
What you are seeking is a maximum number of requests per connection.
Or said another way, a maximum number of requests per pipelined HTTP/1.1 connection.
This desired behavior will only exist on HTTP/1.1 (Jetty HTTP Client doesn't talk HTTP/1.0, so that's out. And HTTP/2 has no such concept)
Look at the various HttpClient.set*Connection() methods, and you'll see a variety of options that might suite you.
If you fail to find one that matches your needs, please file an issue at https://github.com/eclipse/jetty.project/issues/new
Upvotes: 0