on master help sign in
Retry on response and connection timeouts by default
7f2b8e3Mark Karpov
CHANGELOG.md+5
@@ -1,3 +1,8 @@
1+## Req 3.8.0
2+
3+* Adjusted the value of the `httpConfigRetryJudgeException` field of
4+ `defaultHttpConfig` to retry on response timeouts and connection timeouts.
5+
1## Req 3.7.0
6## Req 3.7.0
2
7
3* Added `reqCb`, a function that allows you to modify the `Request` object
8* Added `reqCb`, a function that allows you to modify the `Request` object
Network/HTTP/Req.hs+11−2
@@ -716,7 +716,9 @@ data HttpConfig = HttpConfig
716 -- @since 0.3.0
716 -- @since 0.3.0
717 httpConfigRetryJudge :: forall b. RetryStatus -> L.Response b -> Bool,
717 httpConfigRetryJudge :: forall b. RetryStatus -> L.Response b -> Bool,
718 -- | Similar to 'httpConfigRetryJudge', but is used to decide when to
718 -- | Similar to 'httpConfigRetryJudge', but is used to decide when to
719− -- retry requests that resulted in an exception.
719+ -- retry requests that resulted in an exception. By default it retries
720+ -- on response timeout and connection timeout (changed in version
721+ -- /3.8.0/).
720 --
722 --
721 -- @since 3.4.0
723 -- @since 3.4.0
722 httpConfigRetryJudgeException :: RetryStatus -> SomeException -> Bool,
724 httpConfigRetryJudgeException :: RetryStatus -> SomeException -> Bool,
@@ -750,7 +752,14 @@ defaultHttpConfig =
750 598, -- (Informal convention) Network read timeout error
752 598, -- (Informal convention) Network read timeout error
751 599 -- (Informal convention) Network connect timeout error
753 599 -- (Informal convention) Network connect timeout error
752 ],
754 ],
753− httpConfigRetryJudgeException = \_ _ -> False,
755+ httpConfigRetryJudgeException = \_ e ->
756+ case fromException e of
757+ Just (L.HttpExceptionRequest _ c) ->
758+ case c of
759+ L.ResponseTimeout -> True
760+ L.ConnectionTimeout -> True
761+ _ -> False
762+ _ -> False,
754 httpConfigBodyPreviewLength = 1024
763 httpConfigBodyPreviewLength = 1024
755 }
764 }
756 where
765 where