From 13c5bf66c305c08a2a1af26e48115b667d141b18 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Thu, 28 Jul 2016 19:59:33 +0300 Subject: [PATCH] feat(headers): add Content-Location header Closes #870 --- src/header/common/content_location.rs | 44 +++++++++++++++++++++++++++ src/header/common/mod.rs | 2 ++ 2 files changed, 46 insertions(+) create mode 100644 src/header/common/content_location.rs diff --git a/src/header/common/content_location.rs b/src/header/common/content_location.rs new file mode 100644 index 0000000000..1b3eb8b47c --- /dev/null +++ b/src/header/common/content_location.rs @@ -0,0 +1,44 @@ +header! { + /// `Content-Location` header, defined in + /// [RFC7231](https://tools.ietf.org/html/rfc7231#section-3.1.4.2) + /// + /// The header can be used by both the client in requests and the server + /// in resposes with different semantics. Client sets `Content-Location` + /// to refer to the URI where original representation of the body was + /// obtained. + /// + /// In responses `Content-Location` represents URI for the representation + /// that was content negotiated, created or for the response payload. + /// + /// # ABNF + /// ```plain + /// Content-Location = absolute-URI / partial-URI + /// ``` + /// + /// # Example values + /// * `/hypertext/Overview.html` + /// * `http://www.example.org/hypertext/Overview.html` + /// + /// # Examples + /// + /// ``` + /// use hyper::header::{Headers, ContentLocation}; + /// + /// let mut headers = Headers::new(); + /// headers.set(ContentLocation("/hypertext/Overview.html".to_owned())); + /// ``` + /// ``` + /// use hyper::header::{Headers, ContentLocation}; + /// + /// let mut headers = Headers::new(); + /// headers.set(ContentLocation("http://www.example.org/hypertext/Overview.html".to_owned())); + /// ``` + // TODO: use URL + (ContentLocation, "Content-Location") => [String] + + test_content_location { + test_header!(partial_query, vec![b"/hypertext/Overview.html?q=tim"]); + + test_header!(absolute, vec![b"http://www.example.org/hypertext/Overview.html"]); + } +} diff --git a/src/header/common/mod.rs b/src/header/common/mod.rs index 8d7d6ff427..8ce40fdf8f 100644 --- a/src/header/common/mod.rs +++ b/src/header/common/mod.rs @@ -27,6 +27,7 @@ pub use self::content_disposition::{ContentDisposition, DispositionType, Disposi pub use self::content_length::ContentLength; pub use self::content_encoding::ContentEncoding; pub use self::content_language::ContentLanguage; +pub use self::content_location::ContentLocation; pub use self::content_range::{ContentRange, ContentRangeSpec}; pub use self::content_type::ContentType; pub use self::cookie::Cookie; @@ -389,6 +390,7 @@ mod content_disposition; mod content_encoding; mod content_language; mod content_length; +mod content_location; mod content_range; mod content_type; mod date;