From c79e6f0aa53ec1d88197f5284afa85ac96ebe718 Mon Sep 17 00:00:00 2001 From: Jonathan Reem Date: Sun, 23 Nov 2014 22:30:26 -0800 Subject: [PATCH] feat(headers): Added a HeaderFormatter for getting the HTTP representation of a header. --- src/header/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/header/mod.rs b/src/header/mod.rs index 41c07abd..3588b2d5 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -423,6 +423,19 @@ impl hash::Hash for CaseInsensitive { } } +/// A wrapper around any Header with a Show impl that calls fmt_header. +/// +/// This can be used like so: `format!("{}", ShowHeader(header))` to +/// get the representation of a Header which will be written to an +/// outgoing TcpStream. +pub struct HeaderFormatter(H); + +impl Show for HeaderFormatter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.fmt_header(f) + } +} + #[cfg(test)] mod tests { use std::io::MemReader;