Description
If a response meets all of the following criteria...
- it was retrieved over a Unix domain socket (using the sample code)
- the body is chunked (ie. has the header
Transfer-Encoding: chunked)
- the body is incomplete (ie. does not have a trailing
0\r\n\r\n chunk), such as when streaming events from a Docker daemon with the events API
- the application is running on Linux
...then calling close() on Response takes quite a long time. The amount of time seems to be related to whatever has been set with readTimeout() on OkHttpClient (ie. if the timeout is 3s, closing the response takes just over 3s, if the timeout is 20s, closing the response takes just over 20s).
This behaviour does not occur if any of the following is true:
- the body is not chunked
- the body is chunked but complete (ie. has a trailing
0\r\n\r\n chunk)
- the application is running on OS X
Steps to reproduce
I've created a sample application that demonstrates this behaviour.
Expected behaviour
Calling Response.close() takes a very short period of time (few milliseconds max).
Actual behaviour
Calling Response.close() takes quite some time, and seems to be roughly equal to readTimeout.