use bytes::Bytes; use http::uri::{self, Authority, Scheme, Uri};
use util::{IterExt, TryFromValues}; use HeaderValue;
/// The `Origin` header. /// /// The `Origin` header is a version of the `Referer` header that is used for all HTTP fetches and `POST`s whose CORS flag is set. /// This header is often used to inform recipients of the security context of where the request was initiated. /// /// Following the spec, [https://fetch.spec.whatwg.org/#origin-header][url], the value of this header is composed of /// a String (scheme), Host (host/port) /// /// [url]: https://fetch.spec.whatwg.org/#origin-header /// /// # Examples /// /// ``` /// # extern crate headers; /// use headers::Origin; /// /// let origin = Origin::NULL; /// ``` #[derive(Clone, Debug, PartialEq, Eq, Hash)] pubstruct Origin(OriginOrNull);
/// Get the "scheme" part of this origin. #[inline] pubfn scheme(&self) -> &str { matchself.0 {
OriginOrNull::Origin(ref scheme, _) => scheme.as_str(),
OriginOrNull::Null => "",
}
}
/// Get the "hostname" part of this origin. #[inline] pubfn hostname(&self) -> &str { matchself.0 {
OriginOrNull::Origin(_, ref auth) => auth.host(),
OriginOrNull::Null => "",
}
}
/// Get the "port" part of this origin. #[inline] pubfn port(&self) -> Option<u16> { matchself.0 {
OriginOrNull::Origin(_, ref auth) => auth.port_u16(),
OriginOrNull::Null => None,
}
}
/// Tries to build a `Origin` from three parts, the scheme, the host and an optional port. pubfn try_from_parts(
scheme: &str,
host: &str,
port: impl Into<Option<u16>>,
) -> Result<Self, InvalidOrigin> { struct MaybePort(Option<u16>);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.