hyper_sync/header/common/
accept_charset.rs

1use header::{Charset, QualityItem};
2
3header! {
4    /// `Accept-Charset` header, defined in
5    /// [RFC7231](http://tools.ietf.org/html/rfc7231#section-5.3.3)
6    ///
7    /// The `Accept-Charset` header field can be sent by a user agent to
8    /// indicate what charsets are acceptable in textual response content.
9    /// This field allows user agents capable of understanding more
10    /// comprehensive or special-purpose charsets to signal that capability
11    /// to an origin server that is capable of representing information in
12    /// those charsets.
13    ///
14    /// # ABNF
15    ///
16    /// ```text
17    /// Accept-Charset = 1#( ( charset / "*" ) [ weight ] )
18    /// ```
19    ///
20    /// # Example values
21    /// * `iso-8859-5, unicode-1-1;q=0.8`
22    ///
23    /// # Examples
24    /// ```
25    /// use hyper_sync::header::{Headers, AcceptCharset, Charset, qitem};
26    ///
27    /// let mut headers = Headers::new();
28    /// headers.set(
29    ///     AcceptCharset(vec![qitem(Charset::Us_Ascii)])
30    /// );
31    /// ```
32    /// ```
33    /// use hyper_sync::header::{Headers, AcceptCharset, Charset, q, QualityItem};
34    ///
35    /// let mut headers = Headers::new();
36    /// headers.set(
37    ///     AcceptCharset(vec![
38    ///         QualityItem::new(Charset::Us_Ascii, q(900)),
39    ///         QualityItem::new(Charset::Iso_8859_10, q(200)),
40    ///     ])
41    /// );
42    /// ```
43    /// ```
44    /// use hyper_sync::header::{Headers, AcceptCharset, Charset, qitem};
45    ///
46    /// let mut headers = Headers::new();
47    /// headers.set(
48    ///     AcceptCharset(vec![qitem(Charset::Ext("utf-8".to_owned()))])
49    /// );
50    /// ```
51    (AcceptCharset, "Accept-Charset") => (QualityItem<Charset>)+
52
53    test_accept_charset {
54        /// Testcase from RFC
55        test_header!(test1, vec![b"iso-8859-5, unicode-1-1;q=0.8"]);
56    }
57}