hyperx/header/common/location.rs
1header! {
2 /// `Location` header, defined in
3 /// [RFC7231](http://tools.ietf.org/html/rfc7231#section-7.1.2)
4 ///
5 /// The `Location` header field is used in some responses to refer to a
6 /// specific resource in relation to the response. The type of
7 /// relationship is defined by the combination of request method and
8 /// status code semantics.
9 ///
10 /// # ABNF
11 ///
12 /// ```text
13 /// Location = URI-reference
14 /// ```
15 ///
16 /// # Example values
17 /// * `/People.html#tim`
18 /// * `http://www.example.net/index.html`
19 ///
20 /// # Examples
21 ///
22 /// ```
23 /// # extern crate http;
24 /// use hyperx::header::{Location, TypedHeaders};
25 ///
26 /// let mut headers = http::HeaderMap::new();
27 /// headers.encode(&Location::new("/People.html#tim"));
28 /// ```
29 ///
30 /// ```
31 /// # extern crate http;
32 /// use hyperx::header::{Location, TypedHeaders};
33 ///
34 /// let mut headers = http::HeaderMap::new();
35 /// headers.encode(&Location::new("http://www.example.com/index.html"));
36 /// ```
37 // TODO: Use URL
38 (Location, "Location") => Cow[str]
39
40 test_location {
41 // Testcase from RFC
42 test_header!(test1, vec![b"/People.html#tim"]);
43 test_header!(test2, vec![b"http://www.example.net/index.html"]);
44 }
45
46}
47
48bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] });
49
50standard_header!(Location, LOCATION);