From 8143c33bad9146414f14197c39f6d5326d0f0212 Mon Sep 17 00:00:00 2001 From: Michael Killough Date: Sat, 18 Mar 2017 14:13:12 +0700 Subject: [PATCH] feat(headers): add HeaderView.raw() Add HeaderView.raw() which behaves identically to Headers.get_raw(). --- src/header/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/header/mod.rs b/src/header/mod.rs index f538d7507a..af5c1ba76a 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -589,6 +589,12 @@ impl<'a> HeaderView<'a> { pub fn value_string(&self) -> String { ValueString(self.1).to_string() } + + /// Access the raw value of the header. + #[inline] + pub fn raw(&self) -> &Raw { + self.1.raw() + } } impl<'a> fmt::Display for HeaderView<'a> { @@ -913,6 +919,17 @@ mod tests { } } + #[test] + fn test_header_view_raw() { + let mut headers = Headers::new(); + headers.set_raw("foo", vec![b"one".to_vec(), b"two".to_vec()]); + for header in headers.iter() { + assert_eq!(header.name(), "foo"); + let values: Vec<&[u8]> = header.raw().iter().collect(); + assert_eq!(values, vec![b"one", b"two"]); + } + } + #[test] fn test_eq() { let mut headers1 = Headers::new();