hyperx/header/common/content_location.rs
1header! {
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 responses 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 ///
15 /// ```text
16 /// Content-Location = absolute-URI / partial-URI
17 /// ```
18 ///
19 /// # Example values
20 ///
21 /// * `/hypertext/Overview.html`
22 /// * `http://www.example.org/hypertext/Overview.html`
23 ///
24 /// # Examples
25 ///
26 /// ```
27 /// # extern crate http;
28 /// use hyperx::header::{ContentLocation, TypedHeaders};
29 ///
30 /// let mut headers = http::HeaderMap::new();
31 /// headers.encode(&ContentLocation("/hypertext/Overview.html".to_owned()));
32 /// ```
33 ///
34 /// ```
35 /// # extern crate http;
36 /// use hyperx::header::{ContentLocation, TypedHeaders};
37 ///
38 /// let mut headers = http::HeaderMap::new();
39 /// headers.encode(&ContentLocation("http://www.example.org/hypertext/Overview.html".to_owned()));
40 /// ```
41 // TODO: use URL
42 (ContentLocation, "Content-Location") => [String]
43
44 test_content_location {
45 test_header!(partial_query, vec![b"/hypertext/Overview.html?q=tim"]);
46
47 test_header!(absolute, vec![b"http://www.example.org/hypertext/Overview.html"]);
48 }
49}
50
51standard_header!(ContentLocation, CONTENT_LOCATION);