http-client 0.7.2.1 → 0.7.3
raw patch · 3 files changed
+29/−12 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.HTTP.Client.Internal: withSocket :: (Socket -> IO ()) -> Maybe HostAddress -> String -> Int -> (Socket -> IO a) -> IO a
Files
- ChangeLog.md +4/−0
- Network/HTTP/Client/Connection.hs +24/−11
- http-client.cabal +1/−1
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for http-client +## 0.7.3++* Added `withSocket` to `Network.HTTP.Client.Connection`.+ ## 0.7.2.1 * Fix bug in `useProxySecureWithoutConnect`.
Network/HTTP/Client/Connection.hs view
@@ -10,6 +10,7 @@ , openSocketConnectionSize , makeConnection , socketConnection+ , withSocket ) where import Data.ByteString (ByteString, empty)@@ -144,7 +145,17 @@ -> String -- ^ host -> Int -- ^ port -> IO Connection-openSocketConnectionSize tweakSocket chunksize hostAddress' host' port' = do+openSocketConnectionSize tweakSocket chunksize hostAddress' host' port' =+ withSocket tweakSocket hostAddress' host' port' $ \ sock ->+ socketConnection sock chunksize++withSocket :: (Socket -> IO ())+ -> Maybe HostAddress+ -> String -- ^ host+ -> Int -- ^ port+ -> (Socket -> IO a)+ -> IO a+withSocket tweakSocket hostAddress' host' port' f = do let hints = NS.defaultHints { NS.addrSocketType = NS.Stream } addrs <- case hostAddress' of Nothing ->@@ -160,16 +171,18 @@ , NS.addrCanonName = Nothing }] - firstSuccessful addrs $ \addr ->- E.bracketOnError- (NS.socket (NS.addrFamily addr) (NS.addrSocketType addr)- (NS.addrProtocol addr))- NS.close- (\sock -> do- NS.setSocketOption sock NS.NoDelay 1- tweakSocket sock- NS.connect sock (NS.addrAddress addr)- socketConnection sock chunksize)+ E.bracketOnError (firstSuccessful addrs $ openSocket tweakSocket) NS.close f++openSocket tweakSocket addr =+ E.bracketOnError+ (NS.socket (NS.addrFamily addr) (NS.addrSocketType addr)+ (NS.addrProtocol addr))+ NS.close+ (\sock -> do+ NS.setSocketOption sock NS.NoDelay 1+ tweakSocket sock+ NS.connect sock (NS.addrAddress addr)+ return sock) firstSuccessful :: [NS.AddrInfo] -> (NS.AddrInfo -> IO a) -> IO a firstSuccessful [] _ = error "getAddrInfo returned empty list"
http-client.cabal view
@@ -1,5 +1,5 @@ name: http-client-version: 0.7.2.1+version: 0.7.3 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