hyper_sync/header/common/te.rs
1use header::{Encoding, QualityItem};
2
3header! {
4 /// `TE` header, defined in
5 /// [RFC7230](http://tools.ietf.org/html/rfc7230#section-4.3)
6 ///
7 /// As RFC7230 states, "The "TE" header field in a request indicates what transfer codings,
8 /// besides chunked, the client is willing to accept in response, and
9 /// whether or not the client is willing to accept trailer fields in a
10 /// chunked transfer coding."
11 ///
12 /// For HTTP/1.1 compliant clients `chunked` transfer codings are assumed to be acceptable and
13 /// so should never appear in this header.
14 ///
15 /// # ABNF
16 ///
17 /// ```text
18 /// TE = "TE" ":" #( t-codings )
19 /// t-codings = "trailers" | ( transfer-extension [ accept-params ] )
20 /// ```
21 ///
22 /// # Example values
23 /// * `trailers`
24 /// * `trailers, deflate;q=0.5`
25 /// * ``
26 ///
27 /// # Examples
28 ///
29 /// ```
30 /// use hyper_sync::header::{Headers, Te, Encoding, qitem};
31 ///
32 /// let mut headers = Headers::new();
33 /// headers.set(
34 /// Te(vec![qitem(Encoding::Trailers)])
35 /// );
36 /// ```
37 ///
38 /// ```
39 /// use hyper_sync::header::{Headers, Te, Encoding, qitem};
40 ///
41 /// let mut headers = Headers::new();
42 /// headers.set(
43 /// Te(vec![
44 /// qitem(Encoding::Trailers),
45 /// qitem(Encoding::Gzip),
46 /// qitem(Encoding::Deflate),
47 /// ])
48 /// );
49 /// ```
50 ///
51 /// ```
52 /// use hyper_sync::header::{Headers, Te, Encoding, QualityItem, q, qitem};
53 ///
54 /// let mut headers = Headers::new();
55 /// headers.set(
56 /// Te(vec![
57 /// qitem(Encoding::Trailers),
58 /// QualityItem::new(Encoding::Gzip, q(600)),
59 /// QualityItem::new(Encoding::EncodingExt("*".to_owned()), q(0)),
60 /// ])
61 /// );
62 /// ```
63 (Te, "TE") => (QualityItem<Encoding>)*
64
65 test_te {
66 // From the RFC
67 test_header!(test1, vec![b"trailers"]);
68 test_header!(test2, vec![b"trailers, deflate;q=0.5"]);
69 test_header!(test3, vec![b""]);
70 }
71}