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