Skip to content

Commit

Permalink
Add low level createConnection/disposeConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Feb 7, 2024
1 parent a1c5e34 commit 6f67e5e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions http-client/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for http-client

## 0.7.17

* Expose low-level createConnection/disposeConnection functions.

## 0.7.16

* Add `responseEarlyHints` field to `Response`, containing a list of all HTTP 103 Early Hints headers received from the server.
Expand Down
18 changes: 18 additions & 0 deletions http-client/Network/HTTP/Client/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module Network.HTTP.Client.Core
, httpRedirect
, httpRedirect'
, withConnection
, createConnection
, disposeConnection
, handleClosedRead
) where

Expand Down Expand Up @@ -298,3 +300,19 @@ withConnection origReq man action = do
mHttpConn <- getConn (mSetProxy man origReq) man
action (managedResource mHttpConn) <* keepAlive mHttpConn
`finally` managedRelease mHttpConn DontReuse

-- | Create a @Connection@ acquired from the given @Manager@.
--
-- You should use this only when you have to read and write interactively
-- through the connection (e.g. connection by the WebSocket protocol), and you need
-- to use a bracket-style combinator and @disposeConnection@
--
-- @since 0.7.17
createConnection :: Request -> Manager -> IO (Managed Connection, Connection, IO ())
createConnection origReq man = do
mHttpConn <- getConn (mSetProxy man origReq) man
return (mHttpConn, managedResource mHttpConn, keepAlive mHttpConn)

-- | Dispose of a @Connection@ acquired from @createConnection@.
disposeConnection :: Managed Connection -> IO ()
disposeConnection = flip managedRelease DontReuse
2 changes: 1 addition & 1 deletion http-client/http-client.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: http-client
version: 0.7.16
version: 0.7.17
synopsis: An HTTP client engine
description: Hackage documentation generation is not reliable. For up to date documentation, please see: <http://www.stackage.org/package/http-client>.
homepage: https://github.com/snoyberg/http-client
Expand Down

0 comments on commit 6f67e5e

Please sign in to comment.