diff --git a/src/header/internals/item.rs b/src/header/internals/item.rs index d60e692203..03ed46a6bc 100644 --- a/src/header/internals/item.rs +++ b/src/header/internals/item.rs @@ -78,6 +78,9 @@ impl Item { Err(_) => () } } + if self.raw.is_some() && self.typed.get_mut(tid).is_some() { + self.raw = OptCell::new(None); + } self.typed.get_mut(tid).map(|typed| unsafe { typed.downcast_mut_unchecked() }) } } diff --git a/src/header/mod.rs b/src/header/mod.rs index d79156dc28..64624e9448 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -670,6 +670,7 @@ mod tests { fn test_get_mutable() { let mut headers = Headers::from_raw(&raw!(b"Content-Length: 10")).unwrap(); *headers.get_mut::().unwrap() = ContentLength(20); + assert_eq!(headers.get_raw("content-length").unwrap(), &[b"20".to_vec()][..]); assert_eq!(*headers.get::().unwrap(), ContentLength(20)); }