hyper_sync/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 /// use hyper_sync::header::{Headers, ContentEncoding, Encoding};
29 ///
30 /// let mut headers = Headers::new();
31 /// headers.set(ContentEncoding(vec![Encoding::Chunked]));
32 /// ```
33 ///
34 /// ```
35 /// use hyper_sync::header::{Headers, ContentEncoding, Encoding};
36 ///
37 /// let mut headers = Headers::new();
38 /// headers.set(
39 /// ContentEncoding(vec![
40 /// Encoding::Gzip,
41 /// Encoding::Chunked,
42 /// ])
43 /// );
44 /// ```
45 (ContentEncoding, "Content-Encoding") => (Encoding)+
46
47 test_content_encoding {
48 /// Testcase from the RFC
49 test_header!(test1, vec![b"gzip"], Some(ContentEncoding(vec![Encoding::Gzip])));
50 }
51}
52
53bench_header!(single, ContentEncoding, { vec![b"gzip".to_vec()] });
54bench_header!(multiple, ContentEncoding, { vec![b"gzip, deflate".to_vec()] });