2018-03-31 02:31:18 +02:00
|
|
|
use header::{IF_MODIFIED_SINCE, HttpDate};
|
2018-03-06 09:43:25 +01:00
|
|
|
|
|
|
|
header! {
|
|
|
|
/// `If-Modified-Since` header, defined in
|
|
|
|
/// [RFC7232](http://tools.ietf.org/html/rfc7232#section-3.3)
|
|
|
|
///
|
|
|
|
/// The `If-Modified-Since` header field makes a GET or HEAD request
|
|
|
|
/// method conditional on the selected representation's modification date
|
|
|
|
/// being more recent than the date provided in the field-value.
|
|
|
|
/// Transfer of the selected representation's data is avoided if that
|
|
|
|
/// data has not changed.
|
|
|
|
///
|
|
|
|
/// # ABNF
|
|
|
|
///
|
|
|
|
/// ```text
|
|
|
|
/// If-Unmodified-Since = HTTP-date
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// # Example values
|
|
|
|
/// * `Sat, 29 Oct 1994 19:43:31 GMT`
|
|
|
|
///
|
|
|
|
/// # Example
|
|
|
|
///
|
|
|
|
/// ```rust
|
2018-03-31 08:07:33 +02:00
|
|
|
/// use actix_web::HttpResponse;
|
2018-03-31 02:31:18 +02:00
|
|
|
/// use actix_web::http::header::IfModifiedSince;
|
2018-03-06 09:43:25 +01:00
|
|
|
/// use std::time::{SystemTime, Duration};
|
|
|
|
///
|
2018-03-31 08:07:33 +02:00
|
|
|
/// let mut builder = HttpResponse::Ok();
|
2018-03-06 09:43:25 +01:00
|
|
|
/// let modified = SystemTime::now() - Duration::from_secs(60 * 60 * 24);
|
|
|
|
/// builder.set(IfModifiedSince(modified.into()));
|
|
|
|
/// ```
|
2018-03-31 02:31:18 +02:00
|
|
|
(IfModifiedSince, IF_MODIFIED_SINCE) => [HttpDate]
|
2018-03-06 09:43:25 +01:00
|
|
|
|
|
|
|
test_if_modified_since {
|
2018-03-24 07:35:52 +01:00
|
|
|
// Test case from RFC
|
2018-03-06 09:43:25 +01:00
|
|
|
test_header!(test1, vec![b"Sat, 29 Oct 1994 19:43:31 GMT"]);
|
2018-03-06 04:28:42 +01:00
|
|
|
}
|
|
|
|
}
|