1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-01-20 14:08:07 +00:00

add referer typed header

This commit is contained in:
Keith Cirkel 2024-08-17 23:12:17 +01:00
parent f5d340878c
commit 3ff861eb29
No known key found for this signature in database
3 changed files with 39 additions and 0 deletions

View file

@ -5,6 +5,7 @@
- Minimum supported Rust version (MSRV) is now 1.75.
- Add `http::header::ContentLocation` typed header.
- Add `http::header::Location` typed header.
- Add `http::header::Referer` typed header.
## 4.9.0

View file

@ -44,6 +44,7 @@ mod location;
mod macros;
mod preference;
mod range;
mod referer;
#[cfg(test)]
pub(crate) use self::macros::common_header_test;
@ -75,6 +76,7 @@ pub use self::{
location::Location,
preference::Preference,
range::{ByteRangeSpec, Range},
referer::Referer,
};
/// Format writer ([`fmt::Write`]) for a [`BytesMut`].

View 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"]);
}
}