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
use header::{Header, HeaderFormat};
use std::fmt;
use header::shared::util::from_one_raw_str;

/// The `Server` header field.
///
/// They can contain any value, so it just wraps a `String`.
#[derive(Clone, PartialEq, Show)]
pub struct Server(pub String);

deref!(Server => String);

impl Header for Server {
    fn header_name(_: Option<Server>) -> &'static str {
        "Server"
    }

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

impl HeaderFormat for Server {
    fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        fmt.write_str(&*self.0)
    }
}

bench_header!(bench, Server, { vec![b"Some String".to_vec()] });