Enum ReferrerPolicy

Source
pub enum ReferrerPolicy {
    NoReferrer,
    NoReferrerWhenDowngrade,
    Origin,
    OriginWhenCrossOrigin,
    SameOrigin,
    StrictOrigin,
    StrictOriginWhenCrossOrigin,
    UnsafeUrl,
}
Expand description

Manages Referrer-Policy header

The Referrer-Policy HTTP response header controls how much referrer information (sent via the Referer header) should be included with requests.

§Values

  • no-referrer: The Referer header will be omitted entirely. No referrer information is sent along with requests.
  • no-referrer-when-downgrade: The Referer header will be omitted entirely. However, if the protected resource URL scheme is HTTPS, then the full path will still be sent as a referrer.
  • origin: Only send the origin of the document as the referrer in all cases. The document https://example.com/page.html will send the referrer https://example.com/.
  • origin-when-cross-origin: Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.
  • same-origin: A referrer will be sent for same-site origins, but cross-origin requests will contain no referrer information.
  • strict-origin: Only send the origin of the document as the referrer when the protocol security level stays the same (HTTPS→HTTPS), but don’t send it to a less secure destination (HTTPS→HTTP).
  • strict-origin-when-cross-origin: Send a full URL when performing a same-origin request, only send the origin when the protocol security level stays the same (HTTPS→HTTPS), and send no header to a less secure destination (HTTPS→HTTP).
  • unsafe-url: Send a full URL (stripped from parameters) when performing a same-origin or cross-origin request. This policy will leak origins and paths from TLS-protected resources to insecure origins. Carefully consider the impact of this setting.

§Examples

use helmet_core::ReferrerPolicy;

let referrer_policy = ReferrerPolicy::no_referrer();

Variants§

§

NoReferrer

§

NoReferrerWhenDowngrade

§

Origin

§

OriginWhenCrossOrigin

§

SameOrigin

§

StrictOrigin

§

StrictOriginWhenCrossOrigin

§

UnsafeUrl

Implementations§

Source§

impl ReferrerPolicy

Source

pub fn no_referrer() -> Self

Source

pub fn no_referrer_when_downgrade() -> Self

Source

pub fn origin() -> Self

Source

pub fn origin_when_cross_origin() -> Self

Source

pub fn same_origin() -> Self

Source

pub fn strict_origin() -> Self

Source

pub fn strict_origin_when_cross_origin() -> Self

Source

pub fn unsafe_url() -> Self

Trait Implementations§

Source§

impl Clone for ReferrerPolicy

Source§

fn clone(&self) -> ReferrerPolicy

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Into<(&'static str, String)> for ReferrerPolicy

Source§

fn into(self) -> Header

Converts this type into the (usually inferred) input type.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.