Skip to content

Commit

Permalink
feat(headers): add HeaderView.raw()
Browse files Browse the repository at this point in the history
Add HeaderView.raw() which behaves identically to Headers.get_raw().
  • Loading branch information
mjkillough committed Mar 18, 2017
1 parent 8554904 commit 8143c33
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 8143c33

Please sign in to comment.