#[non_exhaustive]pub enum HttpRedirectPolicy {
None,
Limited(usize),
}Expand description
HTTP 重定向跟随策略。
通过 HttpClientConfig::redirect 配置。默认
HttpRedirectPolicy::Limited(10),与 reqwest 0.12 的默认策略
reqwest::redirect::Policy::limited(10) 等价:最多跟随 10 次重定向。
该策略只控制 client 级重定向跟随行为,不逐跳校验目标 host,也不会额外
剥离自定义凭证头。需要 SSRF 白名单的调用方应显式设为
HttpRedirectPolicy::None,自行检查 3xx 响应的 Location 后再发起受控请求。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
None
不跟随任何重定向:3xx 原样返回,Location 响应头保留给调用方判断。
Limited(usize)
最多跟随 n 次重定向;超过上限时 reqwest 返回 TooManyRedirects 请求错误。
Limited(0) 与 HttpRedirectPolicy::None 的区别:前者在遇到第一个 3xx 时
返回错误,后者把 3xx 响应原样返回。
Trait Implementations§
Source§impl Clone for HttpRedirectPolicy
impl Clone for HttpRedirectPolicy
impl Copy for HttpRedirectPolicy
Source§impl Debug for HttpRedirectPolicy
impl Debug for HttpRedirectPolicy
Source§impl Default for HttpRedirectPolicy
impl Default for HttpRedirectPolicy
impl Eq for HttpRedirectPolicy
Source§impl PartialEq for HttpRedirectPolicy
impl PartialEq for HttpRedirectPolicy
impl StructuralPartialEq for HttpRedirectPolicy
Auto Trait Implementations§
impl Forget for HttpRedirectPolicy
impl Freeze for HttpRedirectPolicy
impl Move for HttpRedirectPolicy
impl RefUnwindSafe for HttpRedirectPolicy
impl Send for HttpRedirectPolicy
impl Sync for HttpRedirectPolicy
impl Unpin for HttpRedirectPolicy
impl UnsafeUnpin for HttpRedirectPolicy
impl UnwindSafe for HttpRedirectPolicy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more