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
impl ApprovedOrigins
Sourcepub fn parse<I, S>(origins: I) -> Option<Self>
pub fn parse<I, S>(origins: I) -> Option<Self>
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.
Sourcepub fn with_origin(self, origin: &str) -> Option<Self>
pub fn with_origin(self, origin: &str) -> Option<Self>
Add one origin (same rules as ApprovedOrigins::parse); None when it is refused.