hyperx/header/common/
user_agent.rs

1header! {
2    /// `User-Agent` header, defined in
3    /// [RFC7231](http://tools.ietf.org/html/rfc7231#section-5.5.3)
4    ///
5    /// The `User-Agent` header field contains information about the user
6    /// agent originating the request, which is often used by servers to help
7    /// identify the scope of reported interoperability problems, to work
8    /// around or tailor responses to avoid particular user agent
9    /// limitations, and for analytics regarding browser or operating system
10    /// use.  A user agent SHOULD send a User-Agent field in each request
11    /// unless specifically configured not to do so.
12    ///
13    /// # ABNF
14    ///
15    /// ```text
16    /// User-Agent = product *( RWS ( product / comment ) )
17    /// product         = token ["/" product-version]
18    /// product-version = token
19    /// ```
20    ///
21    /// # Example values
22    ///
23    /// * `CERN-LineMode/2.15 libwww/2.17b3`
24    /// * `Bunnies`
25    ///
26    /// # Notes
27    ///
28    /// * The parser does not split the value
29    ///
30    /// # Example
31    ///
32    /// ```
33    /// # extern crate http;
34    /// use hyperx::header::{TypedHeaders, UserAgent};
35    ///
36    /// let mut headers = http::HeaderMap::new();
37    /// headers.encode(&UserAgent::new("hyper/0.5.2"));
38    /// ```
39    (UserAgent, "User-Agent") => Cow[str]
40
41    test_user_agent {
42        // Testcase from RFC
43        test_header!(test1, vec![b"CERN-LineMode/2.15 libwww/2.17b3"]);
44        // Own testcase
45        test_header!(test2, vec![b"Bunnies"], Some(UserAgent::new("Bunnies")));
46    }
47}
48
49standard_header!(UserAgent, USER_AGENT);