use header::{Header, HeaderFormat}; use std::fmt::{mod, Show}; use super::util::from_one_raw_str; /// The `User-Agent` header field. /// /// They can contain any value, so it just wraps a `String`. #[deriving(Clone, PartialEq, Show)] pub struct UserAgent(pub String); impl Header for UserAgent { fn header_name(_: Option) -> &'static str { "User-Agent" } fn parse_header(raw: &[Vec]) -> Option { from_one_raw_str(raw).map(|s| UserAgent(s)) } } impl HeaderFormat for UserAgent { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let UserAgent(ref value) = *self; value.fmt(fmt) } }