Skip to content

Commit

Permalink
fix(headers): don't use Show to write UserAgent header
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Atashian <[email protected]>
  • Loading branch information
retep998 committed Jan 12, 2015
1 parent 9fbf0ae commit c8e334a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/header/common/user_agent.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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());
}

0 comments on commit c8e334a

Please sign in to comment.