1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use reqwest::redirect::Policy as ReqwestPolicy;

/// Determines how to handle HTTP redirects (3xx responses).
pub enum RedirectPolicy {
    /// Don't follow redirects. Return an error in case of a redirect response.
    NoFollow,
    /// Follow a limited number of redirects. Return an error if the maximum number of redirects is reached.
    Limited(usize),
}

impl From<RedirectPolicy> for ReqwestPolicy {
    fn from(policy: RedirectPolicy) -> Self {
        match policy {
            RedirectPolicy::NoFollow => ReqwestPolicy::none(),
            RedirectPolicy::Limited(max) => ReqwestPolicy::limited(max),
        }
    }
}