actix_web/http/header/if_unmodified_since.rs
1use super::{HttpDate, IF_UNMODIFIED_SINCE};
2
3crate::http::header::common_header! {
4 /// `If-Unmodified-Since` header, defined
5 /// in [RFC 7232 ยง3.4](https://datatracker.ietf.org/doc/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 /// ```plain
15 /// If-Unmodified-Since = HTTP-date
16 /// ```
17 ///
18 /// # Example Values
19 /// * `Sat, 29 Oct 1994 19:43:31 GMT`
20 ///
21 /// # Examples
22 ///
23 /// ```
24 /// use std::time::{SystemTime, Duration};
25 /// use actix_web::HttpResponse;
26 /// use actix_web::http::header::IfUnmodifiedSince;
27 ///
28 /// let mut builder = HttpResponse::Ok();
29 /// let modified = SystemTime::now() - Duration::from_secs(60 * 60 * 24);
30 /// builder.insert_header(
31 /// IfUnmodifiedSince(modified.into())
32 /// );
33 /// ```
34 (IfUnmodifiedSince, IF_UNMODIFIED_SINCE) => [HttpDate]
35
36 test_parse_and_format {
37 // Test case from RFC
38 crate::http::header::common_header_test!(test1, [b"Sat, 29 Oct 1994 19:43:31 GMT"]);
39 }
40}