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
use std::fmt;

use header;
use header::shared;
use method::Method;

#[derive(Clone)]
struct AccessControlRequestMethod(pub Method);

impl header::Header for AccessControlRequestMethod {
    #[inline]
    fn header_name(_: Option<AccessControlRequestMethod>) -> &'static str {
        "Access-Control-Request-Method"
    }

    fn parse_header(raw: &[Vec<u8>]) -> Option<AccessControlRequestMethod> {
        shared::from_one_raw_str(raw).map(AccessControlRequestMethod)
    }
}

impl header::HeaderFormat for AccessControlRequestMethod {
    fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let AccessControlRequestMethod(ref method) = *self;
        write!(f, "{}", method)
    }
}