actix_web/http/header/
last_modified.rs

1use super::{HttpDate, LAST_MODIFIED};
2
3crate::http::header::common_header! {
4    /// `Last-Modified` header, defined
5    /// in [RFC 7232 ยง2.2](https://datatracker.ietf.org/doc/html/rfc7232#section-2.2)
6    ///
7    /// The `Last-Modified` header field in a response provides a timestamp
8    /// indicating the date and time at which the origin server believes the
9    /// selected representation was last modified, as determined at the
10    /// conclusion of handling the request.
11    ///
12    /// # ABNF
13    /// ```plain
14    /// Expires = HTTP-date
15    /// ```
16    ///
17    /// # Example Values
18    /// * `Sat, 29 Oct 1994 19:43:31 GMT`
19    ///
20    /// # Examples
21    ///
22    /// ```
23    /// use std::time::{SystemTime, Duration};
24    /// use actix_web::HttpResponse;
25    /// use actix_web::http::header::LastModified;
26    ///
27    /// let mut builder = HttpResponse::Ok();
28    /// let modified = SystemTime::now() - Duration::from_secs(60 * 60 * 24);
29    /// builder.insert_header(
30    ///     LastModified(modified.into())
31    /// );
32    /// ```
33    (LastModified, LAST_MODIFIED) => [HttpDate]
34
35    test_parse_and_format {
36        // Test case from RFC
37        crate::http::header::common_header_test!(test1, [b"Sat, 29 Oct 1994 19:43:31 GMT"]);
38    }
39}