hyper_sync/header/common/
if_unmodified_since.rs

1use header::HttpDate;
2
3header! {
4    /// `If-Unmodified-Since` header, defined in
5    /// [RFC7232](http://tools.ietf.org/html/rfc7232#section-3.4)
6    ///
7    /// The `If-Unmodified-Since` header field makes the request method
8    /// conditional on the selected representation's last modification date
9    /// being earlier than or equal to the date provided in the field-value.
10    /// This field accomplishes the same purpose as If-Match for cases where
11    /// the user agent does not have an entity-tag for the representation.
12    ///
13    /// # ABNF
14    ///
15    /// ```text
16    /// If-Unmodified-Since = HTTP-date
17    /// ```
18    ///
19    /// # Example values
20    ///
21    /// * `Sat, 29 Oct 1994 19:43:31 GMT`
22    ///
23    /// # Example
24    ///
25    /// ```
26    /// use hyper_sync::header::{Headers, IfUnmodifiedSince};
27    /// use std::time::{SystemTime, Duration};
28    ///
29    /// let mut headers = Headers::new();
30    /// let modified = SystemTime::now() - Duration::from_secs(60 * 60 * 24);
31    /// headers.set(IfUnmodifiedSince(modified.into()));
32    /// ```
33    (IfUnmodifiedSince, "If-Unmodified-Since") => [HttpDate]
34
35    test_if_unmodified_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, IfUnmodifiedSince, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] });
42bench_header!(rfc_850, IfUnmodifiedSince, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] });
43bench_header!(asctime, IfUnmodifiedSince, { vec![b"Sun Nov  6 08:49:37 1994".to_vec()] });