@@ -122,6 +122,7 @@ module Network.HTTP.Req
122122 -- $embedding-requests
123123 , MonadHttp (..)
124124 , HttpConfig (..)
125+ , defaultHttpConfig
125126 , Req
126127 , runReq
127128 -- * Request
@@ -224,7 +225,6 @@ import Control.Retry
224225import Data.Aeson (ToJSON (..), FromJSON (..))
225226import Data.ByteString (ByteString)
226227import Data.Data (Data)
227−import Data.Default.Class
228228import Data.Function (on)
229229import Data.IORef
230230import Data.List (nubBy)
@@ -318,7 +318,6 @@ import GHC.Exts (Constraint)
318318-- > import Control.Monad
319319-- > import Control.Monad.IO.Class
320320-- > import Data.Aeson
321−-- > import Data.Default.Class
322321-- > import Data.Maybe (fromJust)
323322-- > import Data.Monoid ((<>))
324323-- > import Data.Text (Text)
@@ -331,7 +330,7 @@ import GHC.Exts (Constraint)
331330-- Make a GET request, grab 5 random bytes:
332331--
333332-- > main :: IO ()
334−-- > main = runReq def $ do
333+-- > main = runReq defaultHttpConfig $ do
335334-- > let n :: Int
336335-- > n = 5
337336-- > bs <- req GET (https "httpbin.org" /: "bytes" /~ n) NoReqBody bsResponse mempty
@@ -341,7 +340,7 @@ import GHC.Exts (Constraint)
341340-- seed of the generator:
342341--
343342-- > main :: IO ()
344−-- > main = runReq def $ do
343+-- > main = runReq defaultHttpConfig $ do
345344-- > let n, seed :: Int
346345-- > n = 5
347346-- > seed = 100
@@ -360,7 +359,7 @@ import GHC.Exts (Constraint)
360359-- > instance FromJSON MyData
361360-- >
362361-- > main :: IO ()
363−-- > main = runReq def $ do
362+-- > main = runReq defaultHttpConfig $ do
364363-- > let myData = MyData
365364-- > { size = 6
366365-- > , color = "Green" }
@@ -370,7 +369,7 @@ import GHC.Exts (Constraint)
370369-- Sending URL-encoded body:
371370--
372371-- > main :: IO ()
373−-- > main = runReq def $ do
372+-- > main = runReq defaultHttpConfig $ do
374373-- > let params =
375374-- > "foo" =: ("bar" :: Text) <>
376375-- > queryFlag "baz"
@@ -380,7 +379,7 @@ import GHC.Exts (Constraint)
380379-- Using various optional parameters and URL that is not known in advance:
381380--
382381-- > main :: IO ()
383−-- > main = runReq def $ do
382+-- > main = runReq defaultHttpConfig $ do
384383-- > -- This is an example of what to do when URL is given dynamically. Of
385384-- > -- course in a real application you may not want to use 'fromJust'.
386385-- > let (url, options) = fromJust (parseUrlHttps "https://httpbin.org/get?foo=bar")
@@ -511,7 +510,10 @@ withReqManager m = liftIO (readIORef globalManager) >>= m
511510globalManager :: IORef L.Manager
512511globalManager = unsafePerformIO $ do
513512 context <- NC.initConnectionContext
514− let settings = L.mkManagerSettingsContext (Just context) def Nothing
513+ let settings = L.mkManagerSettingsContext
514+ (Just context)
515+ (NC.TLSSettingsSimple False False False)
516+ Nothing
515517 manager <- L.newManager settings
516518 newIORef manager
517519{-# NOINLINE globalManager #-}
@@ -552,7 +554,7 @@ class MonadIO m => MonadHttp m where
552554 -- approach to configuration is desirable.
553555
554556 getHttpConfig :: m HttpConfig
555− getHttpConfig = return def
557+ getHttpConfig = return defaultHttpConfig
556558
557559-- | 'HttpConfig' contains general and default settings to be used when
558560-- making HTTP requests.
@@ -615,28 +617,32 @@ data HttpConfig = HttpConfig
615617 -- @since 0.3.0
616618 } deriving Typeable
617619
618−instance Default HttpConfig where
619− def = HttpConfig
620− { httpConfigProxy = Nothing
621− , httpConfigRedirectCount = 10
622− , httpConfigAltManager = Nothing
623− , httpConfigCheckResponse = \_ response preview ->
624− let scode = statusCode response
625− in if 200 <= scode && scode < 300
626− then Nothing
627− else Just (L.StatusCodeException (void response) preview)
628− , httpConfigRetryPolicy = def
629− , httpConfigRetryJudge = \_ response ->
630− statusCode response `elem`
631− [ 408 -- Request timeout
632− , 504 -- Gateway timeout
633− , 524 -- A timeout occurred
634− , 598 -- (Informal convention) Network read timeout error
635− , 599 -- (Informal convention) Network connect timeout error
636− ]
637− }
638− where
639− statusCode = Y.statusCode . L.responseStatus
620+-- | Default value of 'HttpConfig'.
621+--
622+-- @since 2.0.0
623+
624+defaultHttpConfig :: HttpConfig
625+defaultHttpConfig = HttpConfig
626+ { httpConfigProxy = Nothing
627+ , httpConfigRedirectCount = 10
628+ , httpConfigAltManager = Nothing
629+ , httpConfigCheckResponse = \_ response preview ->
630+ let scode = statusCode response
631+ in if 200 <= scode && scode < 300
632+ then Nothing
633+ else Just (L.StatusCodeException (void response) preview)
634+ , httpConfigRetryPolicy = retryPolicyDefault
635+ , httpConfigRetryJudge = \_ response ->
636+ statusCode response `elem`
637+ [ 408 -- Request timeout
638+ , 504 -- Gateway timeout
639+ , 524 -- A timeout occurred
640+ , 598 -- (Informal convention) Network read timeout error
641+ , 599 -- (Informal convention) Network connect timeout error
642+ ]
643+ }
644+ where
645+ statusCode = Y.statusCode . L.responseStatus
640646
641647instance RequestComponent HttpConfig where
642648 getRequestMod HttpConfig {..} = Endo $ \x ->