retina_fetch/
referrer.rs

1// Copyright (C) 2023 Tristan Gerritsen <tristan@thewoosh.org>
2// All Rights Reserved.
3
4use url::Url;
5
6/// Specifies the type of [referrer][spec] a request should be associated with.
7/// Most requests have a specific origin, most likely a script or document, that
8/// initiated/linked the resource pointed to by this request. For example, a
9/// __HTML__ document might have images (`<img>`), and those images should be
10/// requested from a server. To follow web security practices, a HTTP
11/// [`Referer`][http] header should be associated with the request.
12///
13/// [spec]: fetch.spec.whatwg.org/#concept-request-referrer
14/// [http]: https://httpwg.org/specs/rfc9110.html#field.referer
15#[derive(Clone, Debug, Default, PartialEq)]
16pub enum RequestReferrer {
17    /// No referrer was found or associated with this request (for example,
18    /// top-level documents), or the client/server has explicitly disabled
19    /// referrer by [policy][policy].
20    ///
21    /// [policy]: https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-header
22    NoReferrer,
23
24    /// The default value, which specifies that [Fetch][crate::Fetch] should
25    /// determine the referrer using [the algorithm][algo].
26    ///
27    /// [algo]: https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer
28    #[default]
29    Client,
30
31    /// The request was referred to by
32    Url(Url),
33}