@@ -236,6 +236,7 @@ import Data.ByteString qualified as B
236import Data.ByteString.Lazy qualified as BL
236import Data.ByteString.Lazy qualified as BL
237import Data.CaseInsensitive qualified as CI
237import Data.CaseInsensitive qualified as CI
238import Data.Data (Data)
238import Data.Data (Data)
239+import Data.Default.Class (def)
239import Data.Function (on)
240import Data.Function (on)
240import Data.IORef
241import Data.IORef
241import Data.Kind (Constraint, Type)
242import Data.Kind (Constraint, Type)
@@ -584,10 +585,10 @@ req' method url body options m = do
584 withReqManager (m request)
585 withReqManager (m request)
586-- | Perform an action using the global implicit 'L.Manager' that the rest
587-- | Perform an action using the global implicit 'L.Manager' that the rest
587−-- of the library uses. This allows to reuse connections that the
588+-- of the library uses. This allows us to reuse connections that the
588-- 'L.Manager' controls.
589-- 'L.Manager' controls.
589withReqManager :: (MonadIO m) => (L.Manager -> m a) -> m a
590withReqManager :: (MonadIO m) => (L.Manager -> m a) -> m a
590−withReqManager m = liftIO (readIORef globalManager) >>= m
591+withReqManager m = m globalManager
592-- | The global 'L.Manager' that 'req' uses. Here we just go with the
593-- | The global 'L.Manager' that 'req' uses. Here we just go with the
593-- default settings, so users don't need to deal with this manager stuff at
594-- default settings, so users don't need to deal with this manager stuff at
@@ -600,16 +601,16 @@ withReqManager m = liftIO (readIORef globalManager) >>= m
600-- manager. From that moment on the 'IORef' will be just reused—exactly the
601-- manager. From that moment on the 'IORef' will be just reused—exactly the
601-- behavior we want here in order to maximize connection sharing. GHC could
602-- behavior we want here in order to maximize connection sharing. GHC could
602-- spoil the plan by inlining the definition, hence the @NOINLINE@ pragma.
603-- spoil the plan by inlining the definition, hence the @NOINLINE@ pragma.
603−globalManager :: IORef L.Manager
604+globalManager :: L.Manager
604globalManager = unsafePerformIO $ do
605globalManager = unsafePerformIO $ do
605 context <- NC.initConnectionContext
606 context <- NC.initConnectionContext
606 let settings =
607 let settings =
607 L.mkManagerSettingsContext
608 L.mkManagerSettingsContext
608 (Just context)
609 (Just context)
609− (NC.TLSSettingsSimple False False False)
610+ def
611 manager <- L.newManager settings
612 manager <- L.newManager settings
612− newIORef manager
613+ return manager
613{-# NOINLINE globalManager #-}
614{-# NOINLINE globalManager #-}
615----------------------------------------------------------------------------
616----------------------------------------------------------------------------
@@ -715,7 +716,6 @@ data HttpConfig = HttpConfig
715 -- @since 3.6.0
716 -- @since 3.6.0
716 httpConfigBodyPreviewLength :: forall a. (Num a) => a
717 httpConfigBodyPreviewLength :: forall a. (Num a) => a
720-- | The default value of 'HttpConfig'.
720-- | The default value of 'HttpConfig'.
@@ -1024,7 +1024,7 @@ instance (HttpMethod method) => RequestComponent (Tagged "method" method) where
1024-- > -- https://%D1%8E%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4.%D1%80%D1%84
1024-- > -- https://%D1%8E%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4.%D1%80%D1%84
1025data Url (scheme :: Scheme) = Url Scheme (NonEmpty Text)
1025data Url (scheme :: Scheme) = Url Scheme (NonEmpty Text)
1026 -- NOTE The second value is the path segments in reversed order.
1026 -- NOTE The second value is the path segments in reversed order.
1027− deriving (Eq, Ord, Show, Data, Typeable, Generic)
1027+ deriving (Eq, Ord, Show, Data, Generic)
1029type role Url nominal
1029type role Url nominal
@@ -2011,7 +2011,7 @@ data HttpException
2011 | -- | A wrapper with Aeson-produced 'String' describing why decoding
2011 | -- | A wrapper with Aeson-produced 'String' describing why decoding
2012 -- failed
2012 -- failed
2013 JsonHttpException String
2013 JsonHttpException String
2014− deriving (Show, Typeable, Generic)
2014+ deriving (Show, Generic)
2016instance Exception HttpException
2016instance Exception HttpException
@@ -2048,4 +2048,4 @@ data Scheme
2049 | -- | HTTPS
2049 | -- | HTTPS
2051− deriving (Eq, Ord, Show, Data, Typeable, Generic, TH.Lift)
2051+ deriving (Eq, Ord, Show, Data, Generic, TH.Lift)