Skip to main content

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    /// # Note
14    /// This is a request header used for conditional requests. Servers should not send
15    /// `If-Unmodified-Since` in responses; use [`LastModified`](super::LastModified) / the
16    /// `Last-Modified` header instead.
17    ///
18    /// # ABNF
19    /// ```plain
20    /// If-Unmodified-Since = HTTP-date
21    /// ```
22    ///
23    /// # Example Values
24    /// * `Sat, 29 Oct 1994 19:43:31 GMT`
25    ///
26    /// # Examples
27    ///
28    /// ```
29    /// use std::time::{SystemTime, Duration};
30    /// use actix_web::{http::header::IfUnmodifiedSince, test};
31    ///
32    /// let modified = SystemTime::now() - Duration::from_secs(60 * 60 * 24);
33    /// let req = test::TestRequest::default()
34    ///     .insert_header(IfUnmodifiedSince(modified.into()))
35    ///     .to_http_request();
36    /// # let _ = req;
37    /// ```
38    (IfUnmodifiedSince, IF_UNMODIFIED_SINCE) => [HttpDate]
39
40    test_parse_and_format {
41        // Test case from RFC
42        crate::http::header::common_header_test!(test1, [b"Sat, 29 Oct 1994 19:43:31 GMT"]);
43    }
44}