diff --git a/src/header/common/user_agent.rs b/src/header/common/user_agent.rs index 60291e47ed..b49641e33b 100644 --- a/src/header/common/user_agent.rs +++ b/src/header/common/user_agent.rs @@ -1,5 +1,5 @@ use header::{Header, HeaderFormat}; -use std::fmt::{self, Show}; +use std::fmt; use header::shared::util::from_one_raw_str; /// The `User-Agent` header field. @@ -22,10 +22,16 @@ impl Header for UserAgent { impl HeaderFormat for UserAgent { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let UserAgent(ref value) = *self; - value.fmt(fmt) + fmt.write_str(&*self.0) } } bench_header!(bench, UserAgent, { vec![b"cargo bench".to_vec()] }); +#[test] fn test_format() { + use std::borrow::ToOwned; + use header::Headers; + let mut head = Headers::new(); + head.set(UserAgent("Bunnies".to_owned())); + assert!(head.to_string() == "User-Agent: Bunnies\r\n".to_owned()); +}