Trait Policy
trait Policy<B, E>
Trait for the policy on handling redirection responses.
Example
Detecting a cyclic redirection:
use ;
use HashSet;
use ;
Required Methods
fn redirect(self: &mut Self, attempt: &Attempt<'_>) -> Result<Action, E>Invoked when the service received a response with a redirection status code (
3xx).This method returns an
Actionwhich indicates whether the service should follow the redirection.
Provided Methods
fn on_request(self: &mut Self, _request: &mut Request<B>)Invoked right before the service makes a request, regardless of whether it is redirected or not.
This can for example be used to remove sensitive headers from the request or prepare the request in other ways.
The default implementation does nothing.
fn clone_body(self: &Self, _body: &B) -> Option<B>Try to clone a request body before the service makes a redirected request.
If the request body cannot be cloned, return
None.This is not invoked when [
B::size_hint][http_body::Body::size_hint] returns zero, in which caseB::default()will be used to create a new request body.The default implementation returns
None.
Implementors
impl<B, E> Policy for Actionimpl<F, B, E> Policy for CloneBodyFn<F>impl<Bd, E, A, B> Policy for And<A, B>impl<B, E, P> Policy for &mut Pimpl<Bd, E, A, B> Policy for Or<A, B>impl<B, E> Policy for FilterCredentialsimpl<B, E, F> Policy for RedirectFn<F>impl<B, E, P> Policy for Box<P>impl<B, E> Policy for Result<Action, E>impl<B, E> Policy for SameOriginimpl<B, E> Policy for Limited