cogo_http/header/common/
if_modified_since.rs

1use crate::header::HttpDate;
2
3header! {
4    /// `If-Modified-Since` header, defined in
5    /// [RFC7232](http://tools.ietf.org/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    /// # Example
22    /// ```
23    /// # extern crate cogo_http;
24    /// # extern crate time;
25    /// # fn main() {
26    /// // extern crate time;
27    /// 
28    /// use cogo_http::header::{Headers, IfModifiedSince, HttpDate};
29    /// use time::{self, Duration};
30    /// 
31    /// let mut headers = Headers::new();
32    /// headers.set(IfModifiedSince(HttpDate(time::now() - Duration::days(1))));
33    /// # }
34    /// ```
35    (IfModifiedSince, "If-Modified-Since") => [HttpDate]
36
37    test_if_modified_since {
38        // Testcase from RFC
39        test_header!(test1, vec![b"Sat, 29 Oct 1994 19:43:31 GMT"]);
40    }
41}
42
43bench_header!(imf_fixdate, IfModifiedSince, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] });
44bench_header!(rfc_850, IfModifiedSince, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] });
45bench_header!(asctime, IfModifiedSince, { vec![b"Sun Nov  6 08:49:37 1994".to_vec()] });