cogo_http/header/common/
content_encoding.rs

1use crate::header::Encoding;
2
3header! {
4    /// `Content-Encoding` header, defined in
5    /// [RFC7231](http://tools.ietf.org/html/rfc7231#section-3.1.2.2)
6    /// 
7    /// The `Content-Encoding` header field indicates what content codings
8    /// have been applied to the representation, beyond those inherent in the
9    /// media type, and thus what decoding mechanisms have to be applied in
10    /// order to obtain data in the media type referenced by the Content-Type
11    /// header field.  Content-Encoding is primarily used to allow a
12    /// representation's data to be compressed without losing the identity of
13    /// its underlying media type.
14    /// 
15    /// # ABNF
16    /// ```plain
17    /// Content-Encoding = 1#content-coding
18    /// ```
19    /// 
20    /// # Example values
21    /// * `gzip`
22    /// 
23    /// # Examples
24    /// ```
25    /// use cogo_http::header::{Headers, ContentEncoding, Encoding};
26    /// 
27    /// let mut headers = Headers::new();
28    /// headers.set(ContentEncoding(vec![Encoding::Chunked]));
29    /// ```
30    /// ```
31    /// use cogo_http::header::{Headers, ContentEncoding, Encoding};
32    /// 
33    /// let mut headers = Headers::new();
34    /// headers.set(
35    ///     ContentEncoding(vec![
36    ///         Encoding::Gzip,
37    ///         Encoding::Chunked,
38    ///     ])
39    /// );
40    /// ```
41    (ContentEncoding, "Content-Encoding") => (Encoding)+
42
43    test_content_encoding {
44        /// Testcase from the RFC
45        test_header!(test1, vec![b"gzip"], Some(ContentEncoding(vec![Encoding::Gzip])));
46    }
47}
48
49bench_header!(single, ContentEncoding, { vec![b"gzip".to_vec()] });
50bench_header!(multiple, ContentEncoding, { vec![b"gzip, deflate".to_vec()] });