Debian Codegraph @

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

raw
1 use HeaderValue;
2
3 /// `Location` header, defined in
4 /// [RFC7231](http://tools.ietf.org/html/rfc7231#section-7.1.2)
5 ///
6 /// The `Location` header field is used in some responses to refer to a
7 /// specific resource in relation to the response. The type of
8 /// relationship is defined by the combination of request method and
9 /// status code semantics.
10 ///
11 /// # ABNF
12 ///
13 /// ```text
14 /// Location = URI-reference
15 /// ```
16 ///
17 /// # Example values
18 /// * `/People.html#tim`
19 /// * `http://www.example.net/index.html`
20 ///
21 /// # Examples
22 ///
23 #[derive(Clone, Debug, PartialEq)]
24 pub struct Location(HeaderValue);
25
26 derive_header! {
27 Location(_),
28 name: LOCATION
29 }
30
31 #[cfg(test)]
32 mod tests {
33 use super::super::test_decode;
34 use super::*;
35
36 #[test]
37 fn absolute_uri() {
38 let s = "http://www.example.net/index.html";
39 let loc = test_decode::<Location>(&[s]).unwrap();
40
41 assert_eq!(loc, Location(HeaderValue::from_static(s)));
42 }
43
44 #[test]
45 fn relative_uri_with_fragment() {
46 let s = "/People.html#tim";
47 let loc = test_decode::<Location>(&[s]).unwrap();
48
49 assert_eq!(loc, Location(HeaderValue::from_static(s)));
50 }
51 }