refactor(headers): Use header!() macro for 3 headers with a "*" value
`If-Match`, `If-None-Match` and `Vary` headers are either a "*" value meaning that the header matches every possible item or a list of items, one of them must be matched to fulfil the condition. BREAKING CHANGE: `If-Match`, `If-None-Match` and `Vary` item variant name changed to `Items`
This commit is contained in:
		| @@ -1,9 +1,23 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{self}; | ||||
| use header::parsing::{from_comma_delimited, fmt_comma_delimited, from_one_raw_str}; | ||||
| use unicase::UniCase; | ||||
|  | ||||
| /// The `Allow` header. | ||||
| header! { | ||||
|     #[doc="`Vary` header, defined in [RFC7231](https://tools.ietf.org/html/rfc7231#section-7.1.4)"] | ||||
|     #[doc=""] | ||||
|     #[doc="The \"Vary\" header field in a response describes what parts of a"] | ||||
|     #[doc="request message, aside from the method, Host header field, and"] | ||||
|     #[doc="request target, might influence the origin server's process for"] | ||||
|     #[doc="selecting and representing this response.  The value consists of"] | ||||
|     #[doc="either a single asterisk (\"*\") or a list of header field names"] | ||||
|     #[doc="(case-insensitive)."] | ||||
|     #[doc=""] | ||||
|     #[doc="# ABNF"] | ||||
|     #[doc="```plain"] | ||||
|     #[doc="Vary = \"*\" / 1#field-name"] | ||||
|     #[doc="```"] | ||||
|     (Vary, "Vary") => {Any / (UniCase<String>)+} | ||||
| } | ||||
|  | ||||
| /*/// The `Allow` header. | ||||
| /// See also https://tools.ietf.org/html/rfc7231#section-7.1.4 | ||||
|  | ||||
| #[derive(Clone, PartialEq, Debug)] | ||||
| @@ -38,7 +52,7 @@ impl HeaderFormat for Vary { | ||||
|             Vary::Headers(ref fields) => { fmt_comma_delimited(fmt, &fields[..]) } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| }*/ | ||||
|  | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
| @@ -53,8 +67,8 @@ mod tests { | ||||
|         assert_eq!(vary, Some(Vary::Any)); | ||||
|  | ||||
|         vary = Header::parse_header([b"etag,cookie,allow".to_vec()].as_ref()); | ||||
|         assert_eq!(vary, Some(Vary::Headers(vec!["eTag".parse().unwrap(), | ||||
|                                                  "cookIE".parse().unwrap(), | ||||
|                                                  "AlLOw".parse().unwrap(),]))); | ||||
|         assert_eq!(vary, Some(Vary::Items(vec!["eTag".parse().unwrap(), | ||||
|                                                 "cookIE".parse().unwrap(), | ||||
|                                                 "AlLOw".parse().unwrap(),]))); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user