Files
hyper/src/header/common/allow.rs
Florian Hartwig 3e456f00f9 fix(rustup): rustc 1.0.0-nightly (123a754cb 2015-03-24)
* fix `extern crate` declaration for rustc-serialize
* enable `into_cow` feature
* replace as_slice() calls by as_ref and enable `convert` feature
* use `core` feature in doc tests
2015-03-25 20:55:42 +01:00

32 lines
1.0 KiB
Rust

use method::Method;
/// The `Allow` header.
/// See also https://tools.ietf.org/html/rfc7231#section-7.4.1
#[derive(Clone, PartialEq, Debug)]
pub struct Allow(pub Vec<Method>);
impl_list_header!(Allow,
"Allow",
Vec<Method>);
#[cfg(test)]
mod tests {
use super::Allow;
use header::Header;
use method::Method::{self, Options, Get, Put, Post, Delete, Head, Trace, Connect, Patch, Extension};
#[test]
fn test_allow() {
let mut allow: Option<Allow>;
allow = Header::parse_header([b"OPTIONS,GET,PUT,POST,DELETE,HEAD,TRACE,CONNECT,PATCH,fOObAr".to_vec()].as_ref());
assert_eq!(allow, Some(Allow(vec![Options, Get, Put, Post, Delete, Head, Trace, Connect, Patch, Extension("fOObAr".to_string())])));
allow = Header::parse_header([b"".to_vec()].as_ref());
assert_eq!(allow, Some(Allow(Vec::<Method>::new())));
}
}
bench_header!(bench, Allow, { vec![b"OPTIONS,GET,PUT,POST,DELETE,HEAD,TRACE,CONNECT,PATCH,fOObAr".to_vec()] });