1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
use unicase::UniCase;
header! {
/// `Vary` header, defined in [RFC7231](https://tools.ietf.org/html/rfc7231#section-7.1.4)
///
/// The "Vary" header field in a response describes what parts of a
/// request message, aside from the method, Host header field, and
/// request target, might influence the origin server's process for
/// selecting and representing this response. The value consists of
/// either a single asterisk ("*") or a list of header field names
/// (case-insensitive).
///
/// # ABNF
/// ```plain
/// Vary = "*" / 1#field-name
/// ```
///
/// # Example values
/// * `accept-encoding, accept-language`
///
/// # Example
/// ```
/// use hyper::header::{Headers, Vary};
///
/// let mut headers = Headers::new();
/// headers.set(Vary::Any);
/// ```
///
/// # Example
/// ```
/// # extern crate hyper;
/// # extern crate unicase;
/// # fn main() {
/// // extern crate unicase;
///
/// use hyper::header::{Headers, Vary};
/// use unicase::UniCase;
///
/// let mut headers = Headers::new();
/// headers.set(
/// Vary::Items(vec![
/// UniCase("accept-encoding".to_owned()),
/// UniCase("accept-language".to_owned()),
/// ])
/// );
/// # }
/// ```
(Vary, "Vary") => {Any / (UniCase<String>)+}
test_vary {
test_header!(test1, vec![b"accept-encoding, accept-language"]);
#[test]
fn test2() {
let mut vary: ::Result<Vary>;
vary = Header::parse_header([b"*".to_vec()].as_ref());
assert_eq!(vary.ok(), Some(Vary::Any));
vary = Header::parse_header([b"etag,cookie,allow".to_vec()].as_ref());
assert_eq!(vary.ok(), Some(Vary::Items(vec!["eTag".parse().unwrap(),
"cookIE".parse().unwrap(),
"AlLOw".parse().unwrap(),])));
}
}
}