Refactor Redirect API (#741)

Changed the redirect types to be from the `redirect` module:

- `reqwest::RedirectPolicy` is now `reqwest::redirect::Policy`
- `reqwest::RedirectAttempt` is now `reqwest::redirect::Attempt`
- `reqwest::RedirectAction` is now `reqwest::redirect::Action`

Changed behavior of default policy to no longer check for redirect loops
(loops should still be caught eventually by the maximum limit).

Removed the `too_many_redirects` and `loop_detected` methods from
`Action`.

Added `error` to `Action` that can be passed any error type.

Closes #717
This commit is contained in:
Sean McArthur
2019-12-16 15:57:09 -08:00
committed by GitHub
parent 382f1c0e6a
commit ce43f80d8b
7 changed files with 123 additions and 144 deletions

View File

@@ -212,12 +212,8 @@ pub(crate) fn request<E: Into<BoxError>>(e: E) -> Error {
Error::new(Kind::Request, Some(e))
}
pub(crate) fn loop_detected(url: Url) -> Error {
Error::new(Kind::Redirect, Some("infinite redirect loop detected")).with_url(url)
}
pub(crate) fn too_many_redirects(url: Url) -> Error {
Error::new(Kind::Redirect, Some("too many redirects")).with_url(url)
pub(crate) fn redirect<E: Into<BoxError>>(e: E, url: Url) -> Error {
Error::new(Kind::Redirect, Some(e)).with_url(url)
}
pub(crate) fn status_code(url: Url, status: StatusCode) -> Error {