|
| 1 | +use header::{Encoding, QualityItem}; |
| 2 | + |
| 3 | +header! { |
| 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 | + /// ```plain |
| 17 | + /// TE = "TE" ":" #( t-codings ) |
| 18 | + /// t-codings = "trailers" | ( transfer-extension [ accept-params ] ) |
| 19 | + /// ``` |
| 20 | + /// |
| 21 | + /// # Example values |
| 22 | + /// * `trailers` |
| 23 | + /// * `trailers, deflate;q=0.5` |
| 24 | + /// * `` |
| 25 | + /// |
| 26 | + /// # Examples |
| 27 | + /// ``` |
| 28 | + /// use hyper::header::{Headers, TE, Encoding, qitem}; |
| 29 | + /// |
| 30 | + /// let mut headers = Headers::new(); |
| 31 | + /// headers.set( |
| 32 | + /// TE(vec![qitem(Encoding::Trailers)]) |
| 33 | + /// ); |
| 34 | + /// ``` |
| 35 | + /// ``` |
| 36 | + /// use hyper::header::{Headers, TE, Encoding, qitem}; |
| 37 | + /// |
| 38 | + /// let mut headers = Headers::new(); |
| 39 | + /// headers.set( |
| 40 | + /// TE(vec![ |
| 41 | + /// qitem(Encoding::Trailers), |
| 42 | + /// qitem(Encoding::Gzip), |
| 43 | + /// qitem(Encoding::Deflate), |
| 44 | + /// ]) |
| 45 | + /// ); |
| 46 | + /// ``` |
| 47 | + /// ``` |
| 48 | + /// use hyper::header::{Headers, TE, Encoding, QualityItem, Quality, qitem}; |
| 49 | + /// |
| 50 | + /// let mut headers = Headers::new(); |
| 51 | + /// headers.set( |
| 52 | + /// TE(vec![ |
| 53 | + /// qitem(Encoding::Trailers), |
| 54 | + /// QualityItem::new(Encoding::Gzip, Quality(600)), |
| 55 | + /// QualityItem::new(Encoding::EncodingExt("*".to_owned()), Quality(0)), |
| 56 | + /// ]) |
| 57 | + /// ); |
| 58 | + /// ``` |
| 59 | + (TE, "TE") => (QualityItem<Encoding>)* |
| 60 | + |
| 61 | + test_te { |
| 62 | + // From the RFC |
| 63 | + test_header!(test1, vec![b"trailers"]); |
| 64 | + test_header!(test2, vec![b"trailers, deflate;q=0.5"]); |
| 65 | + test_header!(test3, vec![b""]); |
| 66 | + } |
| 67 | +} |
0 commit comments