hyperx/header/common/
last_modified.rs

1use header::HttpDate;
2
3header! {
4    /// `Last-Modified` header, defined in
5    /// [RFC7232](http://tools.ietf.org/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    ///
14    /// ```text
15    /// Expires = HTTP-date
16    /// ```
17    ///
18    /// # Example values
19    ///
20    /// * `Sat, 29 Oct 1994 19:43:31 GMT`
21    ///
22    /// # Example
23    ///
24    /// ```
25    /// # extern crate http;
26    /// use hyperx::header::{LastModified, TypedHeaders};
27    /// use std::time::{SystemTime, Duration};
28    ///
29    /// let mut headers = http::HeaderMap::new();
30    /// let modified = SystemTime::now() - Duration::from_secs(60 * 60 * 24);
31    /// headers.encode(&LastModified(modified.into()));
32    /// ```
33    (LastModified, "Last-Modified") => [HttpDate]
34
35    test_last_modified {
36        // Testcase from RFC
37        test_header!(test1, vec![b"Sat, 29 Oct 1994 19:43:31 GMT"]);}
38}
39
40bench_header!(imf_fixdate, LastModified, { vec![b"Mon, 07 Nov 1994 08:48:37 GMT".to_vec()] });
41bench_header!(rfc_850, LastModified, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] });
42bench_header!(asctime, LastModified, { vec![b"Sun Nov  6 08:49:37 1994".to_vec()] });
43
44standard_header!(LastModified, LAST_MODIFIED);