on master help sign in
Add ‘httpConfigBodyPreviewLength’ to ‘HttpConfig’
56a0851Philipp Volguine
CHANGELOG.md+5
@@ -1,3 +1,8 @@
1+## Req 3.6.0
2+
3+* Added the `httpConfigBodyPreviewLength` configuration parameter to
4+ `HttpConfig`.
5+
1## Req 3.5.0
6## Req 3.5.0
2
7
3* Made `Req` an instance of `MonadUnliftIO`. [Issue
8* Made `Req` an instance of `MonadUnliftIO`. [Issue
Network/HTTP/Req.hs+8−10
@@ -491,7 +491,7 @@ reqBr method url body options consume = req' method url body options $ \request
491 (const openResponse)
491 (const openResponse)
492 )
492 )
493 )
493 )
494− (preview, r') <- grabPreview bodyPreviewLength r
494+ (preview, r') <- grabPreview httpConfigBodyPreviewLength r
495 mapM_ LI.throwHttp (httpConfigCheckResponse request r' preview)
495 mapM_ LI.throwHttp (httpConfigCheckResponse request r' preview)
496 consume r'
496 consume r'
497 )
497 )
@@ -671,7 +671,11 @@ data HttpConfig = HttpConfig
671 -- retry requests that resulted in an exception.
671 -- retry requests that resulted in an exception.
672 --
672 --
673 -- @since 3.4.0
673 -- @since 3.4.0
674− httpConfigRetryJudgeException :: RetryStatus -> SomeException -> Bool
674+ httpConfigRetryJudgeException :: RetryStatus -> SomeException -> Bool,
675+ -- | Max length of preview fragment of response body.
676+ --
677+ -- @since 3.6.0
678+ httpConfigBodyPreviewLength :: forall a. Num a => a
675 }
679 }
676 deriving (Typeable)
680 deriving (Typeable)
677
681
@@ -698,7 +702,8 @@ defaultHttpConfig =
698 598, -- (Informal convention) Network read timeout error
702 598, -- (Informal convention) Network read timeout error
699 599 -- (Informal convention) Network connect timeout error
703 599 -- (Informal convention) Network connect timeout error
700 ],
704 ],
701− httpConfigRetryJudgeException = \_ _ -> False
705+ httpConfigRetryJudgeException = \_ _ -> False,
706+ httpConfigBodyPreviewLength = 1024
702 }
707 }
703 where
708 where
704 statusCode = Y.statusCode . L.responseStatus
709 statusCode = Y.statusCode . L.responseStatus
@@ -1843,10 +1848,3 @@ data Scheme
1843 | -- | HTTPS
1848 | -- | HTTPS
1844 Https
1849 Https
1845 deriving (Eq, Ord, Show, Data, Typeable, Generic, TH.Lift)
1850 deriving (Eq, Ord, Show, Data, Typeable, Generic, TH.Lift)
1846−
1847−----------------------------------------------------------------------------
1848−-- Constants
1849−
1850−-- | Max length of preview fragment of response body.
1851−bodyPreviewLength :: Num a => a
1852−bodyPreviewLength = 1024
pure-tests/Network/HTTP/ReqSpec.hsmode 100644 → 100755+1
@@ -427,6 +427,7 @@ instance Arbitrary HttpConfig where
427 httpConfigRetryPolicy = retryPolicyDefault
427 httpConfigRetryPolicy = retryPolicyDefault
428 httpConfigRetryJudge _ _ = False
428 httpConfigRetryJudge _ _ = False
429 httpConfigRetryJudgeException _ _ = False
429 httpConfigRetryJudgeException _ _ = False
430+ httpConfigBodyPreviewLength = 1024
430 return HttpConfig {..}
431 return HttpConfig {..}
431
432
432instance Show HttpConfig where
433instance Show HttpConfig where