headers_ext/common/location.rs
1use ::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//TODO: make this a `Uri`?
24#[derive(Clone, Debug, PartialEq, Header)]
25pub struct Location(HeaderValue);
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30 use super::super::test_decode;
31
32 #[test]
33 fn absolute_uri() {
34 let s = "http://www.example.net/index.html";
35 let loc = test_decode::<Location>(&[s]).unwrap();
36
37 assert_eq!(loc, Location(HeaderValue::from_static(s)));
38 }
39
40 #[test]
41 fn relative_uri_with_fragment() {
42 let s = "/People.html#tim";
43 let loc = test_decode::<Location>(&[s]).unwrap();
44
45 assert_eq!(loc, Location(HeaderValue::from_static(s)));
46 }
47}