apache/httpcore — pull request #8 by hirthwork (2014-11-12 17:21:54+00:00)
Title: Set EmptyInputStream in entity instead of ContentLengthInputStream(in, 0)

# Problem description
1. If HttpClient receives response with `Content-Length: 0` the connection won't be returned to connection pool until `entity.getContent().close()` is called (it is usually done by `EntityUtils.consume()`) or any read operation performed on `entity.getContent()`.
2. If CloseableHttpResponse.close() is called on such response without entity consuming, the connection will be closed, despite of any keep-alive strategies.

Here the [sample](https://gist.github.com/hirthwork/6f4ebb047e77a61f644e) illustrating first problem. Trying to execute two sequential requests with maxPerRoute set to 1 we will hit TimeoutException because connection from first response (which has empty body) won't be returned to pool.

# Problem analysis
Current BHttpConnectionBase contract is to set input stream regardless of `Content-Length:` header value. The only way to distinct empty response entities from regular ones is to set entity content to some pre-defined value which can indicate that entity is not streaming, so `MainClientExec.execute()` can return connection to pool immediately.

# Solution
Introduce `EmptyInputStream` singleton which will be set as BasicHttpEntity content on zero length responses. `isStreaming()` will check content for nullness and equality with `EmptyInputStream.INSTANCE`.
As alternative, suggested solution can be applied to 4.4.x branch, while for 5.0 branch contract can be broken and `prepareInput()` will return null for zero-length responses.

# Test
Aforementioned sample can be used for this solution testing.