cogo_http/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    /// ```plain
12    /// Location = URI-reference
13    /// ```
14    ///
15    /// # Example values
16    /// * `/People.html#tim`
17    /// * `http://www.example.net/index.html`
18    ///
19    /// # Examples
20    /// ```
21    /// use cogo_http::header::{Headers, Location};
22    ///
23    /// let mut headers = Headers::new();
24    /// headers.set(Location("/People.html#tim".to_owned()));
25    /// ```
26    /// ```
27    /// use cogo_http::header::{Headers, Location};
28    ///
29    /// let mut headers = Headers::new();
30    /// headers.set(Location("http://www.example.com/index.html".to_owned()));
31    /// ```
32    // TODO: Use URL
33    (Location, "Location") => [String]
34
35    test_location {
36        // Testcase from RFC
37        test_header!(test1, vec![b"/People.html#tim"]);
38        test_header!(test2, vec![b"http://www.example.net/index.html"]);
39    }
40
41}
42
43bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] });