Skip to content

Commit

Permalink
feat(headers): add remove_raw method and corresponding test
Browse files Browse the repository at this point in the history
It was previously impossible to remove a header set by set_raw()

Closes #326
  • Loading branch information
yberreby committed Feb 22, 2015
1 parent 41fd8de commit 4f57678
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ impl Headers {
self.data.insert(UniCase(name.into_cow()), Item::new_raw(value));
}

/// Remove a header set by set_raw
pub fn remove_raw(&mut self, name: &str) {
self.data.remove(&UniCase(name.into_cow()));
}

/// Get a reference to the header field's value, if it exists.
pub fn get<H: Header + HeaderFormat>(&self) -> Option<&H> {
self.get_or_parse::<H>().map(|item| {
Expand Down Expand Up @@ -662,6 +667,14 @@ mod tests {
assert_eq!(headers.get(), Some(&ContentLength(20)));
}

#[test]
fn test_remove_raw() {
let mut headers = Headers::new();
headers.set_raw("content-LENGTH", vec![b"20".to_vec()]);
headers.remove_raw("content-LENGTH");
assert_eq!(headers.get_raw("Content-length"), None);
}

#[test]
fn test_len() {
let mut headers = Headers::new();
Expand Down

0 comments on commit 4f57678

Please sign in to comment.