hyper_sync/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    /// use hyper_sync::header::{Headers, Location};
24    ///
25    /// let mut headers = Headers::new();
26    /// headers.set(Location::new("/People.html#tim"));
27    /// ```
28    ///
29    /// ```
30    /// use hyper_sync::header::{Headers, Location};
31    ///
32    /// let mut headers = Headers::new();
33    /// headers.set(Location::new("http://www.example.com/index.html"));
34    /// ```
35    // TODO: Use URL
36    (Location, "Location") => Cow[str]
37
38    test_location {
39        // Testcase from RFC
40        test_header!(test1, vec![b"/People.html#tim"]);
41        test_header!(test2, vec![b"http://www.example.net/index.html"]);
42    }
43
44}
45
46bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] });