1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-02-21 11:54:47 +01:00

add content-location typed header

This commit is contained in:
Keith Cirkel 2024-08-17 23:11:42 +01:00
parent 9b6a93d72c
commit 342242a0e7
No known key found for this signature in database
3 changed files with 40 additions and 0 deletions

View File

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

View File

@ -0,0 +1,36 @@
use super::{Uri, CONTENT_LOCATION};
crate::http::header::common_header! {
/// `Content-Location` header, defined
/// in [RFC 7231 §3.1.4.2](https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.4.2)
///
/// The "Content-Location" header field references a URI that can be used
/// as an identifier for a specific resource corresponding to the
/// representation in this message's payload.
///
/// # ABNF
/// ```plain
/// Content-Location = 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::ContentLocation;
///
/// let mut builder = HttpResponse::Created();
/// builder.insert_header(
/// ContentLocation("http://www.example.org".parse::<Uri>().unwrap())
/// );
/// ```
(ContentLocation, CONTENT_LOCATION) => [Uri]
test_parse_and_format {
crate::http::header::common_header_test!(test1, [b"http://www.example.org/hypertext/Overview.html"]);
}
}

View File

@ -14,6 +14,7 @@ use std::fmt;
// - the few typed headers from actix-http
// - header parsing utils
pub use actix_http::header::*;
pub use actix_http::Uri;
use bytes::{Bytes, BytesMut};
mod accept;
@ -25,6 +26,7 @@ mod cache_control;
mod content_disposition;
mod content_language;
mod content_length;
mod content_location;
mod content_range;
mod content_type;
mod date;
@ -55,6 +57,7 @@ pub use self::{
content_disposition::{ContentDisposition, DispositionParam, DispositionType},
content_language::ContentLanguage,
content_length::ContentLength,
content_location::ContentLocation,
content_range::{ContentRange, ContentRangeSpec},
content_type::ContentType,
date::Date,