mirror of
https://github.com/actix/actix-web.git
synced 2025-03-06 11:31:15 +00:00
add referer typed header
This commit is contained in:
parent
f5d340878c
commit
3ff861eb29
3 changed files with 39 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
- Minimum supported Rust version (MSRV) is now 1.75.
|
- Minimum supported Rust version (MSRV) is now 1.75.
|
||||||
- Add `http::header::ContentLocation` typed header.
|
- Add `http::header::ContentLocation` typed header.
|
||||||
- Add `http::header::Location` typed header.
|
- Add `http::header::Location` typed header.
|
||||||
|
- Add `http::header::Referer` typed header.
|
||||||
|
|
||||||
## 4.9.0
|
## 4.9.0
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ mod location;
|
||||||
mod macros;
|
mod macros;
|
||||||
mod preference;
|
mod preference;
|
||||||
mod range;
|
mod range;
|
||||||
|
mod referer;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(crate) use self::macros::common_header_test;
|
pub(crate) use self::macros::common_header_test;
|
||||||
|
@ -75,6 +76,7 @@ pub use self::{
|
||||||
location::Location,
|
location::Location,
|
||||||
preference::Preference,
|
preference::Preference,
|
||||||
range::{ByteRangeSpec, Range},
|
range::{ByteRangeSpec, Range},
|
||||||
|
referer::Referer,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Format writer ([`fmt::Write`]) for a [`BytesMut`].
|
/// Format writer ([`fmt::Write`]) for a [`BytesMut`].
|
||||||
|
|
36
actix-web/src/http/header/referer.rs
Normal file
36
actix-web/src/http/header/referer.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use super::{Uri, REFERER};
|
||||||
|
|
||||||
|
crate::http::header::common_header! {
|
||||||
|
/// `Referer` header, defined
|
||||||
|
/// in [RFC 7231 §5.5.2](https://datatracker.ietf.org/doc/html/rfc7231#section-5.5.2)
|
||||||
|
///
|
||||||
|
/// The "Referer" (sic) header field allows the user agent to specify a
|
||||||
|
/// URI reference for the resource from which the target URI was obtained
|
||||||
|
/// (i.e., the "referrer", though the field name is misspelled).
|
||||||
|
///
|
||||||
|
/// # ABNF
|
||||||
|
/// ```plain
|
||||||
|
/// Referer = absolute-URI / partial-URI
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// # Example Values
|
||||||
|
/// * `http://www.example.org/hypertext/Overview.html`
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use actix_web::HttpResponse;
|
||||||
|
/// use actix_http::Uri;
|
||||||
|
/// use actix_web::http::header::Referer;
|
||||||
|
///
|
||||||
|
/// let mut builder = HttpResponse::Ok();
|
||||||
|
/// builder.insert_header(
|
||||||
|
/// Referer("http://www.example.org".parse::<Uri>().unwrap())
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
(Referer, REFERER) => [Uri]
|
||||||
|
|
||||||
|
test_parse_and_format {
|
||||||
|
crate::http::header::common_header_test!(test1, [b"http://www.example.org/hypertext/Overview.html"]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue