http-client-tls 0.2.3 → 0.2.4
raw patch · 4 files changed
+52/−4 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.HTTP.Client.TLS: getGlobalManager :: IO Manager
+ Network.HTTP.Client.TLS: setGlobalManager :: Manager -> IO ()
Files
- ChangeLog.md +4/−0
- Network/HTTP/Client/TLS.hs +31/−1
- README.md +15/−1
- http-client-tls.cabal +2/−2
ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.2.4++* Global manager+ ## 0.2.3 * Exception catching cleanup
Network/HTTP/Client/TLS.hs view
@@ -1,9 +1,16 @@ {-# LANGUAGE ScopedTypeVariables #-} -- | Support for making connections via the connection package and, in turn, -- the tls package suite.+--+-- Recommended reading: <https://github.com/commercialhaskell/jump/blob/master/doc/http-client.md> module Network.HTTP.Client.TLS- ( tlsManagerSettings+ ( -- * Settings+ tlsManagerSettings , mkManagerSettings+ -- * Global manager+ , getGlobalManager+ , setGlobalManager+ -- * Internal , getTlsConnection ) where @@ -15,7 +22,11 @@ import Network.Socket (HostAddress) import qualified Network.TLS as TLS import qualified Data.ByteString as S+import Data.IORef (IORef, newIORef, readIORef, writeIORef)+import System.IO.Unsafe (unsafePerformIO) +-- | Create a TLS-enabled 'ManagerSettings' with the given 'NC.TLSSettings' and+-- 'NC.SockSettings' mkManagerSettings :: NC.TLSSettings -> Maybe NC.SockSettings -> ManagerSettings@@ -54,6 +65,7 @@ in handle $ throwIO . wrapper } +-- | Default TLS-enabled manager settings tlsManagerSettings :: ManagerSettings tlsManagerSettings = mkManagerSettings def Nothing @@ -106,3 +118,21 @@ -- on the socket. But when this is called the socket might be -- already closed, and we get a @ResourceVanished@. (NC.connectionClose conn `Control.Exception.catch` \(_ :: IOException) -> return ())++-- | Evil global manager, to make life easier for the common use case+globalManager :: IORef Manager+globalManager = unsafePerformIO (newManager tlsManagerSettings >>= newIORef)+{-# NOINLINE globalManager #-}++-- | Get the current global 'Manager'+--+-- @since 0.2.4+getGlobalManager :: IO Manager+getGlobalManager = readIORef globalManager+{-# INLINE getGlobalManager #-}++-- | Set the current global 'Manager'+--+-- @since 0.2.4+setGlobalManager :: Manager -> IO ()+setGlobalManager = writeIORef globalManager
README.md view
@@ -1,4 +1,18 @@ ## http-client-tls +Full tutorial docs are available at:+https://github.com/commercialhaskell/jump/blob/master/doc/http-client.md+ Use the http-client package with the pure-Haskell tls package for secure-connections+connections. For the most part, you'll just want to replace+`defaultManagerSettings` with `tlsManagerSettings`, e.g.:++```haskell+import Network.HTTP.Client+import Network.HTTP.Client.TLS++main :: IO ()+main = do+ manager <- newManager tlsManagerSettings+ ...+```
http-client-tls.cabal view
@@ -1,7 +1,7 @@ name: http-client-tls-version: 0.2.3+version: 0.2.4 synopsis: http-client backend using the connection package and tls library-description: Intended for use by higher-level libraries, such as http-conduit.+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 license: MIT license-file: LICENSE