on master help sign in
Add ‘httpConfigBodyPreviewLength’ to ‘HttpConfig’

This allows us to configure the length of preview fragment of response body.

commit56a0851c0585f9949d88249fbe7e743bb8b7a2cb authorPhilipp Volguine <phil.volguine@gmail.com> dateSat 5 Sep 2020, 19:55 (6 years ago) parent25a03c5
3 files changed+14−10
CHANGELOG.md+5 Network/HTTP/Req.hs+8−10 pure-tests/Network/HTTP/ReqSpec.hs+1
CHANGELOG.md+5
@@ -1,3 +1,8 @@
1+## Req 3.6.0
2+
3+* Added the `httpConfigBodyPreviewLength` configuration parameter to
4+ `HttpConfig`.
5+
16## Req 3.5.0
27
38* 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
491491 (const openResponse)
492492 )
493493 )
494− (preview, r') <- grabPreview bodyPreviewLength r
494+ (preview, r') <- grabPreview httpConfigBodyPreviewLength r
495495 mapM_ LI.throwHttp (httpConfigCheckResponse request r' preview)
496496 consume r'
497497 )
@@ -671,7 +671,11 @@ data HttpConfig = HttpConfig
671671 -- retry requests that resulted in an exception.
672672 --
673673 -- @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
675679 }
676680 deriving (Typeable)
677681
@@ -698,7 +702,8 @@ defaultHttpConfig =
698702 598, -- (Informal convention) Network read timeout error
699703 599 -- (Informal convention) Network connect timeout error
700704 ],
701− httpConfigRetryJudgeException = \_ _ -> False
705+ httpConfigRetryJudgeException = \_ _ -> False,
706+ httpConfigBodyPreviewLength = 1024
702707 }
703708 where
704709 statusCode = Y.statusCode . L.responseStatus
@@ -1843,10 +1848,3 @@ data Scheme
18431848 | -- | HTTPS
18441849 Https
18451850 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
427427 httpConfigRetryPolicy = retryPolicyDefault
428428 httpConfigRetryJudge _ _ = False
429429 httpConfigRetryJudgeException _ _ = False
430+ httpConfigBodyPreviewLength = 1024
430431 return HttpConfig {..}
431432
432433instance Show HttpConfig where