Merge pull request #841 from hyperium/pr/833
fix(headers): Remove raw part when getting mutable reference to typed header
This commit is contained in:
		| @@ -78,6 +78,9 @@ impl Item { | |||||||
|                 Err(_) => () |                 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() }) |         self.typed.get_mut(tid).map(|typed| unsafe { typed.downcast_mut_unchecked() }) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -670,6 +670,7 @@ mod tests { | |||||||
|     fn test_get_mutable() { |     fn test_get_mutable() { | ||||||
|         let mut headers = Headers::from_raw(&raw!(b"Content-Length: 10")).unwrap(); |         let mut headers = Headers::from_raw(&raw!(b"Content-Length: 10")).unwrap(); | ||||||
|         *headers.get_mut::<ContentLength>().unwrap() = ContentLength(20); |         *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)); |         assert_eq!(*headers.get::<ContentLength>().unwrap(), ContentLength(20)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user