mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-09 03:25:28 +00:00
Previously, a partially consumed response body closed via CloseableHttpResponse.close or HttpEntity.close would fully consume remaining bytes (via close), however it would not release the connection for reuse. If CloseableHttpResponse.close was called, it would follow the close with a discard/disconnect, however if only the entity was closed, the connection would remain in a checked-out (leaked) state. Now, we take advantage of the fact that closing a response stream on any reusable connection is required to drain bytes on closure. Failures are detected by writeTo and the stream returned by getContent, so we can be confident that we will not return a broken connection to the pool.