Struct surf::middleware::Redirect [−][src]
A middleware which attempts to follow HTTP redirects.
Implementations
impl Redirect
[src]
pub fn new(attempts: u8) -> Self
[src]
Create a new instance of the Redirect middleware, which attempts to follow redirects up to as many times as specified.
Consider using Redirect::default()
for the default number of redirect attempts.
This middleware will follow redirects from the Location
header if the server returns
any of the following http response codes:
- 301 Moved Permanently
- 302 Found
- 303 See other
- 307 Temporary Redirect
- 308 Permanent Redirect
Errors
An error will be passed through the middleware stack if the value of the Location
header is not a validly parsing url.
Caveats
This will presently make at least one additional HTTP request before the actual request to determine if there is a redirect that should be followed, so as to preserve any request body.
Examples
let req = surf::get("https://httpbin.org/redirect/2"); let client = surf::client().with(surf::middleware::Redirect::new(5)); let mut res = client.send(req).await?; dbg!(res.body_string().await?);
Trait Implementations
impl Debug for Redirect
[src]
impl Default for Redirect
[src]
fn default() -> Self
[src]
Create a new instance of the Redirect middleware, which attempts to follow up to 3 redirects (not including the actual request).
impl Middleware for Redirect
[src]
Auto Trait Implementations
impl RefUnwindSafe for Redirect
impl Send for Redirect
impl Sync for Redirect
impl Unpin for Redirect
impl UnwindSafe for Redirect
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,