hyperx/header/common/
content_encoding.rs

1use 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    ///
17    /// ```text
18    /// Content-Encoding = 1#content-coding
19    /// ```
20    ///
21    /// # Example values
22    ///
23    /// * `gzip`
24    ///
25    /// # Examples
26    ///
27    /// ```
28    /// # extern crate http;
29    /// use hyperx::header::{ContentEncoding, Encoding, TypedHeaders};
30    ///
31    /// let mut headers = http::HeaderMap::new();
32    /// headers.encode(&ContentEncoding(vec![Encoding::Chunked]));
33    /// ```
34    ///
35    /// ```
36    /// # extern crate http;
37    /// use hyperx::header::{ContentEncoding, Encoding, TypedHeaders};
38    ///
39    /// let mut headers = http::HeaderMap::new();
40    /// headers.encode(
41    ///     &ContentEncoding(vec![
42    ///         Encoding::Gzip,
43    ///         Encoding::Chunked,
44    ///     ])
45    /// );
46    /// ```
47    (ContentEncoding, "Content-Encoding") => (Encoding)+
48
49    test_content_encoding {
50        // Testcase from the RFC
51        test_header!(test1, vec![b"gzip"], Some(ContentEncoding(vec![Encoding::Gzip])));
52    }
53}
54
55standard_header!(ContentEncoding, CONTENT_ENCODING);
56
57bench_header!(single, ContentEncoding, { vec![b"gzip".to_vec()] });
58bench_header!(multiple, ContentEncoding, { vec![b"gzip, deflate".to_vec()] });