requiem_http/header/common/
if_modified_since.rs

1use crate::header::{HttpDate, IF_MODIFIED_SINCE};
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    /// ```rust
25    /// use requiem_http::Response;
26    /// use requiem_http::http::header::IfModifiedSince;
27    /// use std::time::{SystemTime, Duration};
28    ///
29    /// let mut builder = Response::Ok();
30    /// let modified = SystemTime::now() - Duration::from_secs(60 * 60 * 24);
31    /// builder.set(IfModifiedSince(modified.into()));
32    /// ```
33    (IfModifiedSince, IF_MODIFIED_SINCE) => [HttpDate]
34
35    test_if_modified_since {
36        // Test case from RFC
37        test_header!(test1, vec![b"Sat, 29 Oct 1994 19:43:31 GMT"]);
38    }
39}