pub struct Redirect { /* private fields */ }Expand description
A middleware which attempts to follow HTTP redirects.
Implementations§
Source§impl Redirect
impl Redirect
Sourcepub fn new(attempts: u8) -> Self
pub fn new(attempts: u8) -> Self
Create a new instance of the Redirect middleware, which attempts to follow redirects
up to attempts times.
Consider using Redirect::default for the default of 3 redirect attempts.
This middleware follows redirects from the Location header when the server returns
any of the following status codes:
- 301 Moved Permanently
- 302 Found
- 303 See Other
- 307 Temporary Redirect
- 308 Permanent Redirect
§Errors
Returns an error if the Location header value is not a valid URL, or if it contains
non-ASCII bytes (e.g. a UTF-8 encoded path).
§Examples
Http::get("https://httpbin.org/redirect/2")
.middleware(crux_http::middleware::Redirect::default())
.build()
.then_send(Event::ReceiveResponse);Trait Implementations§
Source§impl Middleware for Redirect
impl Middleware for Redirect
Source§fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
request: Request,
client: Client,
next: Next<'life1>,
) -> Pin<Box<dyn Future<Output = Result<RawResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
request: Request,
client: Client,
next: Next<'life1>,
) -> Pin<Box<dyn Future<Output = Result<RawResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Asynchronously handle the request, and return a response.
Auto Trait Implementations§
impl Freeze for Redirect
impl RefUnwindSafe for Redirect
impl Send for Redirect
impl Sync for Redirect
impl Unpin for Redirect
impl UnsafeUnpin for Redirect
impl UnwindSafe for Redirect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more