refactor(headers): Introduce header!() macro, improve documentation

The new macro handles single value headers, list headers, and list
headers with at least one item.
It creates the item for the header and contains its documentation. The
new macro allows handling
more header cases in the future, it will also be possible to include
tests inside the macro.

BREAKING CHANGE: Removed impl_header!() and impl_list_header!() macros,
use new header!() macro.
This commit is contained in:
Pyfisch
2015-04-02 12:41:04 +02:00
parent eeba13b34d
commit 262c450f90
19 changed files with 367 additions and 225 deletions

View File

@@ -1,10 +1,21 @@
use header::HttpDate;
/// The `If-Unmodified-Since` header field.
#[derive(Copy, PartialEq, Clone, Debug)]
pub struct IfUnmodifiedSince(pub HttpDate);
impl_header!(IfUnmodifiedSince, "If-Unmodified-Since", HttpDate);
header! {
#[doc="`If-Unmodified-Since` header, defined in"]
#[doc="[RFC7232](http://tools.ietf.org/html/rfc7232#section-3.4)"]
#[doc=""]
#[doc="The `If-Unmodified-Since` header field makes the request method"]
#[doc="conditional on the selected representation's last modification date"]
#[doc="being earlier than or equal to the date provided in the field-value."]
#[doc="This field accomplishes the same purpose as If-Match for cases where"]
#[doc="the user agent does not have an entity-tag for the representation."]
#[doc=""]
#[doc="# ABNF"]
#[doc="```plain"]
#[doc="If-Unmodified-Since = HTTP-date"]
#[doc="```"]
(IfUnmodifiedSince, "If-Unmodified-Since") => [HttpDate]
}
bench_header!(imf_fixdate, IfUnmodifiedSince, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] });
bench_header!(rfc_850, IfUnmodifiedSince, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] });