From 1848e64e1596da1f52751a9b31bdf74150bae3f4 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 13 Sep 2016 08:43:55 +0300 Subject: [PATCH] Introduce global connection context #214 --- http-client-tls/Network/HTTP/Client/TLS.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/http-client-tls/Network/HTTP/Client/TLS.hs b/http-client-tls/Network/HTTP/Client/TLS.hs index 5d977ec2..48bb6b74 100644 --- a/http-client-tls/Network/HTTP/Client/TLS.hs +++ b/http-client-tls/Network/HTTP/Client/TLS.hs @@ -40,7 +40,7 @@ import Data.ByteArray.Encoding (convertToBase, Base (Base16)) mkManagerSettings :: NC.TLSSettings -> Maybe NC.SockSettings -> ManagerSettings -mkManagerSettings = mkManagerSettingsContext Nothing +mkManagerSettings = mkManagerSettingsContext (Just globalContext) -- | Same as 'mkManagerSettings', but also takes an optional -- 'NC.ConnectionContext'. Providing this externally can be an @@ -83,7 +83,11 @@ mkManagerSettingsContext mcontext tls sock = defaultManagerSettings -- | Default TLS-enabled manager settings tlsManagerSettings :: ManagerSettings -tlsManagerSettings = mkManagerSettings def Nothing +tlsManagerSettings = mkManagerSettingsContext (Just globalContext) def Nothing + +globalContext :: NC.ConnectionContext +globalContext = unsafePerformIO NC.initConnectionContext +{-# NOINLINE globalContext #-} getTlsConnection :: Maybe NC.ConnectionContext -> Maybe NC.TLSSettings