Skip to main content

ApprovedOrigins

Struct ApprovedOrigins 

Source
pub struct ApprovedOrigins { /* private fields */ }
Expand description

The origins a request’s redirects may reach besides the origin the request itself started at, set with crate::Request::approved_redirect_origins. An origin is scheme, host and port, compared canonically (scheme and host lowercased, one trailing dot ignored, default ports folded), the same form CredentialScope and the redirect rules use.

The request’s own origin is always approved, so a same-origin redirect never needs an entry; ApprovedOrigins::new() therefore means “this origin only”. A redirect hop outside the set is refused before anything is sent to it, with crate::HttpError::RedirectRefused and RedirectRefusal::UnapprovedOrigin.

The set decides where a redirect may go, not what it carries: a hop to another approved origin still drops credential-named and secret-valued headers, and the address policy still runs on every hop. A request without a set follows redirects to any origin the address policy admits, as before.

Implementations§

Source§

impl ApprovedOrigins

Source

pub fn new() -> Self

The request’s own origin only.

Source

pub fn parse<I, S>(origins: I) -> Option<Self>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Parse origins such as https://downloads.example.com or https://cdn.example.com:8443. A single trailing / is accepted. Returns None when any entry is malformed, is not http/https, or carries userinfo, a path, a query or a fragment; no partial set is returned.

Source

pub fn with_origin(self, origin: &str) -> Option<Self>

Add one origin (same rules as ApprovedOrigins::parse); None when it is refused.

Source

pub fn allows(&self, url: &str) -> bool

True when url is at one of the listed origins. The request’s own origin is not listed here; the clients add it when they check a hop.

Trait Implementations§

Source§

impl Clone for ApprovedOrigins

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ApprovedOrigins

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ApprovedOrigins

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ApprovedOrigins

Source§

impl PartialEq for ApprovedOrigins

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ApprovedOrigins

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.