Skip to content

Commit

Permalink
Merge pull request #841 from hyperium/pr/833
Browse files Browse the repository at this point in the history
fix(headers): Remove raw part when getting mutable reference to typed header
  • Loading branch information
seanmonstar authored Jun 20, 2016
2 parents 6dab63f + f38717e commit d02eb47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/header/internals/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() })
}
}
Expand Down
1 change: 1 addition & 0 deletions src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ContentLength>().unwrap() = ContentLength(20);
assert_eq!(headers.get_raw("content-length").unwrap(), &[b"20".to_vec()][..]);
assert_eq!(*headers.get::<ContentLength>().unwrap(), ContentLength(20));
}

Expand Down

0 comments on commit d02eb47

Please sign in to comment.