pub struct Origin(/* private fields */);Expand description
The scheme-and-authority an Origin names, compared as such.
Lowercased on parse, because RFC 6454 §6.2.2 makes the comparison
case-insensitive for scheme and host: a browser sends HTTP://Example.COM
and a byte-comparing server refuses a page it just served. A path or query
in an Origin is refused outright — the header is scheme-and-host-only,
and a value carrying more is not a value this policy can reason about.
Implementations§
Source§impl Origin
impl Origin
Sourcepub fn host(&self) -> &str
pub fn host(&self) -> &str
The host this origin names, without the scheme and without the port.
Brackets are stripped, so an IPv6 host reads as ::1 rather than as
[::1], which is the form every comparison in this module wants.
Sourcepub fn is_loopback(&self) -> bool
pub fn is_loopback(&self) -> bool
Whether this origin names the loopback interface.
Exactly localhost, 127.0.0.1 or ::1, and nothing else. This is
the check that keeps a rebinding defence from rebinding: localhost
is compared whole, so localhost.evil.example and 127.0.0.1.evil.example
are not loopback and are not excused by this.
Trait Implementations§
impl Eq for Origin
Source§impl FromStr for Origin
impl FromStr for Origin
Source§fn from_str(value: &str) -> Result<Self, Self::Err>
fn from_str(value: &str) -> Result<Self, Self::Err>
§Errors
OriginError::Empty for an empty value,
OriginError::UnsupportedScheme for a scheme other than HTTP(S), and
OriginError::NotAnOrigin for anything that is not
scheme://host[:port] — including a bare host, a trailing path, or a
null origin, which is what a sandboxed frame and some redirects send.