When http.keepAlive is set to false to disable http connection reuse,
the jdk makes an assumption that the http server will mimic the "Connection:close" header in the http response. The http 1.1 spec does not require this. It only states in 8.1.2.1 that "if either the client or the server sends the close token in the Connection header, that request becomes the
last one for the connection."
When http.keepAlive is set to false, HttpURLConnection puts a Connection:close
entry in the http request. When an http 1.1 response is processed by
HttpClient, it checks for the Connection:close entry. When one isn't
found, it sets keepAliveConnections to 2. Then in the finished() method,
it only checks the value of keepAlive instead of isKeepingAlive(). In
this case, it still caches the connection.
the jdk makes an assumption that the http server will mimic the "Connection:close" header in the http response. The http 1.1 spec does not require this. It only states in 8.1.2.1 that "if either the client or the server sends the close token in the Connection header, that request becomes the
last one for the connection."
When http.keepAlive is set to false, HttpURLConnection puts a Connection:close
entry in the http request. When an http 1.1 response is processed by
HttpClient, it checks for the Connection:close entry. When one isn't
found, it sets keepAliveConnections to 2. Then in the finished() method,
it only checks the value of keepAlive instead of isKeepingAlive(). In
this case, it still caches the connection.