Skip to content

Commit 13c5bf6

Browse files
koivunejseanmonstar
authored andcommitted
feat(headers): add Content-Location header
Closes #870
1 parent 1b4a2b7 commit 13c5bf6

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/header/common/content_location.rs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
header! {
2+
/// `Content-Location` header, defined in
3+
/// [RFC7231](https://tools.ietf.org/html/rfc7231#section-3.1.4.2)
4+
///
5+
/// The header can be used by both the client in requests and the server
6+
/// in resposes with different semantics. Client sets `Content-Location`
7+
/// to refer to the URI where original representation of the body was
8+
/// obtained.
9+
///
10+
/// In responses `Content-Location` represents URI for the representation
11+
/// that was content negotiated, created or for the response payload.
12+
///
13+
/// # ABNF
14+
/// ```plain
15+
/// Content-Location = absolute-URI / partial-URI
16+
/// ```
17+
///
18+
/// # Example values
19+
/// * `/hypertext/Overview.html`
20+
/// * `http://www.example.org/hypertext/Overview.html`
21+
///
22+
/// # Examples
23+
///
24+
/// ```
25+
/// use hyper::header::{Headers, ContentLocation};
26+
///
27+
/// let mut headers = Headers::new();
28+
/// headers.set(ContentLocation("/hypertext/Overview.html".to_owned()));
29+
/// ```
30+
/// ```
31+
/// use hyper::header::{Headers, ContentLocation};
32+
///
33+
/// let mut headers = Headers::new();
34+
/// headers.set(ContentLocation("http://www.example.org/hypertext/Overview.html".to_owned()));
35+
/// ```
36+
// TODO: use URL
37+
(ContentLocation, "Content-Location") => [String]
38+
39+
test_content_location {
40+
test_header!(partial_query, vec![b"/hypertext/Overview.html?q=tim"]);
41+
42+
test_header!(absolute, vec![b"http://www.example.org/hypertext/Overview.html"]);
43+
}
44+
}

src/header/common/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub use self::content_disposition::{ContentDisposition, DispositionType, Disposi
2727
pub use self::content_length::ContentLength;
2828
pub use self::content_encoding::ContentEncoding;
2929
pub use self::content_language::ContentLanguage;
30+
pub use self::content_location::ContentLocation;
3031
pub use self::content_range::{ContentRange, ContentRangeSpec};
3132
pub use self::content_type::ContentType;
3233
pub use self::cookie::Cookie;
@@ -389,6 +390,7 @@ mod content_disposition;
389390
mod content_encoding;
390391
mod content_language;
391392
mod content_length;
393+
mod content_location;
392394
mod content_range;
393395
mod content_type;
394396
mod date;

0 commit comments

Comments
 (0)