actix_web/http/header/
if_modified_since.rs

1use super::{HttpDate, IF_MODIFIED_SINCE};
2
3crate::http::header::common_header! {
4    /// `If-Modified-Since` header, defined
5    /// in [RFC 7232 ยง3.3](https://datatracker.ietf.org/doc/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    /// ```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::IfModifiedSince;
27    ///
28    /// let mut builder = HttpResponse::Ok();
29    /// let modified = SystemTime::now() - Duration::from_secs(60 * 60 * 24);
30    /// builder.insert_header(
31    ///     IfModifiedSince(modified.into())
32    /// );
33    /// ```
34    (IfModifiedSince, IF_MODIFIED_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}