diff --git a/http-client/ChangeLog.md b/http-client/ChangeLog.md index cb58bb73..90631d6c 100644 --- a/http-client/ChangeLog.md +++ b/http-client/ChangeLog.md @@ -1,5 +1,9 @@ # Changelog for http-client +## 0.7.20 + +* Fix connectionRead in makeConnection to flush all stacks and throw connectionClosed afterwards. + ## 0.7.19 * Make mockable via `Network.HTTP.Client.Internal.requestAction` [#554](https://github.com/snoyberg/http-client/pull/554) diff --git a/http-client/Network/HTTP/Client/Connection.hs b/http-client/Network/HTTP/Client/Connection.hs index a57da553..efe77a9a 100644 --- a/http-client/Network/HTTP/Client/Connection.hs +++ b/http-client/Network/HTTP/Client/Connection.hs @@ -115,7 +115,10 @@ makeConnection r w c = do return $! Connection { connectionRead = do closed <- readIORef closedVar - when closed $ throwHttp ConnectionClosed + when closed $ do + v <- readIORef istack + -- When the stack is empty and the connection is closed, throw an exception. + when (v == []) $ throwHttp ConnectionClosed join $ atomicModifyIORef istack $ \stack -> case stack of x:xs -> (xs, return x) diff --git a/http-client/http-client.cabal b/http-client/http-client.cabal index a52e892f..94c8feef 100644 --- a/http-client/http-client.cabal +++ b/http-client/http-client.cabal @@ -1,5 +1,5 @@ name: http-client -version: 0.7.19 +version: 0.7.20 synopsis: An HTTP client engine description: Hackage documentation generation is not reliable. For up to date documentation, please see: . homepage: https://github.com/snoyberg/http-client