diff --git a/src/header/mod.rs b/src/header/mod.rs index a59538cde6..d38c41433f 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -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(&self) -> Option<&H> { self.get_or_parse::().map(|item| { @@ -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();