cogo_http/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    /// ```plain
15    /// User-Agent = product *( RWS ( product / comment ) )
16    /// product         = token ["/" product-version]
17    /// product-version = token
18    /// ```
19    ///
20    /// # Example values
21    /// * `CERN-LineMode/2.15 libwww/2.17b3`
22    /// * `Bunnies`
23    ///
24    /// # Notes
25    /// * The parser does not split the value
26    ///
27    /// # Example
28    /// ```
29    /// use cogo_http::header::{Headers, UserAgent};
30    ///
31    /// let mut headers = Headers::new();
32    /// headers.set(UserAgent("hyper/0.5.2".to_owned()));
33    /// ```
34    (UserAgent, "User-Agent") => [String]
35
36    test_user_agent {
37        // Testcase from RFC
38        test_header!(test1, vec![b"CERN-LineMode/2.15 libwww/2.17b3"]);
39        // Own testcase
40        test_header!(test2, vec![b"Bunnies"], Some(UserAgent("Bunnies".to_owned())));
41    }
42}