hyper_sync/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    /// use hyper_sync::header::{Headers, ContentLocation};
28    ///
29    /// let mut headers = Headers::new();
30    /// headers.set(ContentLocation("/hypertext/Overview.html".to_owned()));
31    /// ```
32    ///
33    /// ```
34    /// use hyper_sync::header::{Headers, ContentLocation};
35    ///
36    /// let mut headers = Headers::new();
37    /// headers.set(ContentLocation("http://www.example.org/hypertext/Overview.html".to_owned()));
38    /// ```
39    // TODO: use URL
40    (ContentLocation, "Content-Location") => [String]
41
42    test_content_location {
43        test_header!(partial_query, vec![b"/hypertext/Overview.html?q=tim"]);
44
45        test_header!(absolute, vec![b"http://www.example.org/hypertext/Overview.html"]);
46    }
47}