Set Content-Type in header

This commit is contained in:
Dongie Agnir 2016-03-10 16:10:03 -10:00
parent 7d828a8193
commit 0c69442a37

View file

@ -336,9 +336,18 @@ impl Metadata {
/// Extract the parts of a Mime that we care about.
pub fn set_content_type(&mut self, content_type: Option<&Mime>) {
match self.headers {
None => self.headers = Some(Headers::new()),
Some(_) => (),
}
match content_type {
None => (),
Some(mime) => {
if let Some(headers) = self.headers.as_mut() {
headers.set(ContentType(mime.clone()));
}
self.content_type = Some(ContentType(mime.clone()));
let &Mime(_, _, ref parameters) = mime;
for &(ref k, ref v) in parameters {