From 0c69442a37ab0f2370cc075fffdd62bce1521826 Mon Sep 17 00:00:00 2001 From: Dongie Agnir Date: Thu, 10 Mar 2016 16:10:03 -1000 Subject: [PATCH] Set Content-Type in header --- components/net_traits/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index a741bec034c..f32576fcde5 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -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 {