cogo_http/header/common/if_unmodified_since.rs
1use crate::header::HttpDate;
2
3header! {
4 /// `If-Unmodified-Since` header, defined in
5 /// [RFC7232](http://tools.ietf.org/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 /// # 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, IfUnmodifiedSince, HttpDate};
29 /// use time::{self, Duration};
30 ///
31 /// let mut headers = Headers::new();
32 /// headers.set(IfUnmodifiedSince(HttpDate(time::now() - Duration::days(1))));
33 /// # }
34 /// ```
35 (IfUnmodifiedSince, "If-Unmodified-Since") => [HttpDate]
36
37 test_if_unmodified_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, IfUnmodifiedSince, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] });
44bench_header!(rfc_850, IfUnmodifiedSince, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] });
45bench_header!(asctime, IfUnmodifiedSince, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] });