eclipse/vert.x — pull request #876 by ddimensia (2014-07-16 05:41:29+00:00)
Title: Added handling from Connection: close header in HttpClient

This PR is a super set of https://github.com/eclipse/vert.x/pull/875

This adds handling of the 'Connection: close' header that can be returned by a server that wishes for an HTTP/1.1 connection to be treated as non-persistent. In that case the http client should not reuse the connection for subsequent requests and should remove it from the pool.

In addition handling was added for cases where the server closes the connection, without issuing a Connection: close header, that would inform the HttpClientRequests exception handler that the connection was closed. This only happens if a request timeout exception hasn't already occurred and gives the caller a better chance to handle these cases gracefully. Although the correct behavior for pipelining according to the RFC is to resend requests on the closed connection it would be a much larger change as the DefaultHttpClientRequest class would need the ability to retain and reset some of it's state. Since that seemed a little too invasive at this point it seemed like the next best solution would be to give the caller the opportunity to decided to resend rather than simply treating this as a request timeout.

Finally, because of the new connection close handling and associated exception when there are pending requests, several tests needed to be updated so that the server side of the test properly ended the response. The tests wouldn't fail but would print the ClosedChannelException to stdout when running tests.