hyperx/header/common/
if_modified_since.rs

1use header::HttpDate;
2
3header! {
4    /// `If-Modified-Since` header, defined in
5    /// [RFC7232](http://tools.ietf.org/html/rfc7232#section-3.3)
6    ///
7    /// The `If-Modified-Since` header field makes a GET or HEAD request
8    /// method conditional on the selected representation's modification date
9    /// being more recent than the date provided in the field-value.
10    /// Transfer of the selected representation's data is avoided if that
11    /// data has not changed.
12    ///
13    /// # ABNF
14    ///
15    /// ```text
16    /// If-Unmodified-Since = HTTP-date
17    /// ```
18    ///
19    /// # Example values
20    /// * `Sat, 29 Oct 1994 19:43:31 GMT`
21    ///
22    /// # Example
23    ///
24    /// ```
25    /// # extern crate http;
26    /// use hyperx::header::{IfModifiedSince, TypedHeaders};
27    /// use std::time::{SystemTime, Duration};
28    ///
29    /// let mut headers = http::HeaderMap::new();
30    /// let modified = SystemTime::now() - Duration::from_secs(60 * 60 * 24);
31    /// headers.encode(&IfModifiedSince(modified.into()));
32    /// ```
33    (IfModifiedSince, "If-Modified-Since") => [HttpDate]
34
35    test_if_modified_since {
36        // Testcase from RFC
37        test_header!(test1, vec![b"Sat, 29 Oct 1994 19:43:31 GMT"]);
38    }
39}
40
41bench_header!(imf_fixdate, IfModifiedSince, { vec![b"Mon, 07 Nov 1994 08:48:37 GMT".to_vec()] });
42bench_header!(rfc_850, IfModifiedSince, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] });
43bench_header!(asctime, IfModifiedSince, { vec![b"Sun Nov  6 08:49:37 1994".to_vec()] });
44
45standard_header!(IfModifiedSince, IF_MODIFIED_SINCE);