pub fn custom<T>(policy: T) -> RedirectPolicy
    where
        T: Fn(RedirectAttempt) -> RedirectAction + Send + Sync + 'static,
    {
        RedirectPolicy {
            inner: Policy::Custom(Box::new(policy)),
        }
    }
/// Create a custom RedirectPolicy using the passed function.
///
/// # Note
///
/// The default RedirectPolicy handles redirect loops and a maximum loop
/// chain, but the custom variant does not do that for you automatically.
/// The custom policy should have some way of handling those.
///
/// Information on the next request and previous requests can be found
/// on the [`RedirectAttempt`] argument passed to the closure.
///
/// Actions can be conveniently created from methods on the
/// [`RedirectAttempt`].
///
/// # Example
///
/// ```rust
/// # use reqwest::{Error, RedirectPolicy};
/// #
/// # fn run() -> Result<(), Error> {
/// let custom = RedirectPolicy::custom(|attempt| {
///     if attempt.previous().len() > 5 {
///         attempt.too_many_redirects()
///     } else if attempt.url().host_str() == Some("example.domain") {
///         // prevent redirects to 'example.domain'
///         attempt.stop()
///     } else {
///         attempt.follow()
///     }
/// });
/// let client = reqwest::Client::builder()
///     .redirect(custom)
///     .build()?;
/// # Ok(())
/// # }
/// ```
///
/// [`RedirectAttempt`]: struct.RedirectAttempt.html
Create a custom RedirectPolicy using the passed function.
Create a custom RedirectPolicy using the passed function .
pub fn custom<T>(policy: T) -> RedirectPolicy
    where
        T: Fn(RedirectAttempt) -> RedirectAction + Send + Sync + 'static,
    {
        RedirectPolicy {
            inner: Policy::Custom(Box::new(policy)),
        }
    }
pub fn custom < T > ( policy : T ) -> RedirectPolicy where T : Fn ( RedirectAttempt ) -> RedirectAction + Send + Sync + ' static , { RedirectPolicy { inner : Policy :: Custom ( Box :: new ( policy ) ) , } }
Create a custom RedirectPolicy using the passed function.
Create a custom RedirectPolicy using the passed function .
policy
T
note
The default RedirectPolicy handles redirect loops and a maximum loop
chain, but the custom variant does not do that for you automatically.
The custom policy should have some way of handling those.

Information on the next request and previous requests can be found
on the [`RedirectAttempt`] argument passed to the closure.

Actions can be conveniently created from methods on the
[`RedirectAttempt`].
The default RedirectPolicy handles redirect loops and a maximum loop chain but the custom variant does not do that for you automatically . The custom policy should have some way of handling those . Information on the next request and previous requests can be found on the [ ` RedirectAttempt ` ] argument passed to the closure . Actions can be conveniently created from methods on the [ ` RedirectAttempt ` ] .
example
None
use reqwest::{error, redirectpolicy};
None
fn run() -> result<(), error> {
let custom = RedirectPolicy::custom(|attempt| {
if attempt.previous().len() > 5 {
attempt.too_many_redirects()
} else if attempt.url().host_str() == Some("example.domain") {
prevent redirects to 'example.domain'
attempt.stop()
} else {
attempt.follow()
}
});
let client = reqwest::Client::builder()
.redirect(custom)
.build()?.
let custom = RedirectPolicy :: custom ( |attempt| { if attempt . previous () . len () > 5 { attempt . too_many_redirects () } else if attempt . url () . host_str () == Some ( " example . domain " ) { prevent redirects to ' example . domain ' attempt . stop () } else { attempt . follow () } } ) ; let client = reqwest :: Client :: builder () . redirect ( custom ) . build () ? .
ok(())
None
}
None