hyper_sync/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 /// use hyper_sync::header::{Headers, UserAgent};
34 ///
35 /// let mut headers = Headers::new();
36 /// headers.set(UserAgent::new("hyper_sync/0.5.2"));
37 /// ```
38 (UserAgent, "User-Agent") => Cow[str]
39
40 test_user_agent {
41 // Testcase from RFC
42 test_header!(test1, vec![b"CERN-LineMode/2.15 libwww/2.17b3"]);
43 // Own testcase
44 test_header!(test2, vec![b"Bunnies"], Some(UserAgent::new("Bunnies")));
45 }
46}