Debian Codegraph @

third_party/rust/headers/src/common/content_location.rs

raw
1 use HeaderValue;
2
3 /// `Content-Location` header, defined in
4 /// [RFC7231](https://tools.ietf.org/html/rfc7231#section-3.1.4.2)
5 ///
6 /// The header can be used by both the client in requests and the server
7 /// in responses with different semantics. Client sets `Content-Location`
8 /// to refer to the URI where original representation of the body was
9 /// obtained.
10 ///
11 /// In responses `Content-Location` represents URI for the representation
12 /// that was content negotiated, created or for the response payload.
13 ///
14 /// # ABNF
15 ///
16 /// ```text
17 /// Content-Location = absolute-URI / partial-URI
18 /// ```
19 ///
20 /// # Example values
21 ///
22 /// * `/hypertext/Overview.html`
23 /// * `http://www.example.org/hypertext/Overview.html`
24 ///
25 /// # Examples
26 ///
27 #[derive(Clone, Debug, PartialEq)]
28 pub struct ContentLocation(HeaderValue);
29
30 derive_header! {
31 ContentLocation(_),
32 name: CONTENT_LOCATION
33 }
34
35 #[cfg(test)]
36 mod tests {
37 use super::super::test_decode;
38 use super::*;
39
40 #[test]
41 fn absolute_uri() {
42 let s = "http://www.example.net/index.html";
43 let loc = test_decode::<ContentLocation>(&[s]).unwrap();
44
45 assert_eq!(loc, ContentLocation(HeaderValue::from_static(s)));
46 }
47
48 #[test]
49 fn relative_uri_with_fragment() {
50 let s = "/People.html#tim";
51 let loc = test_decode::<ContentLocation>(&[s]).unwrap();
52
53 assert_eq!(loc, ContentLocation(HeaderValue::from_static(s)));
54 }
55 }