diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index f8c9a6bb5ea..58a60da2bb1 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -38,6 +38,7 @@ flate2 = "0.2.0" hyper = { version = "0.8", features = [ "serde-serialization" ] } immeta = "0.3.1" log = "0.3.5" +mime = "0.2.0" mime_guess = "1.6.0" openssl = "0.7.6" rustc-serialize = "0.3" diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 0980bfee301..fa5f165a26c 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -59,28 +59,28 @@ pub fn fetch(request: Rc) -> Response { // Substep 2 _ if request.is_navigation_request() => - vec![qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])), + vec![qitem(mime!(Text / Html)), // FIXME: This should properly generate a MimeType that has a // SubLevel of xhtml+xml (https://github.com/hyperium/mime.rs/issues/22) - qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_owned()), vec![])), - QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), q(0.9)), - QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.8))], + qitem(mime!(Application / ("xhtml+xml") )), + QualityItem::new(mime!(Application / Xml), q(0.9)), + QualityItem::new(mime!(_ / _), q(0.8))], // Substep 3 Type::Image => - vec![qitem(Mime(TopLevel::Image, SubLevel::Png, vec![])), + vec![qitem(mime!(Image / Png)), // FIXME: This should properly generate a MimeType that has a // SubLevel of svg+xml (https://github.com/hyperium/mime.rs/issues/22) - qitem(Mime(TopLevel::Image, SubLevel::Ext("svg+xml".to_owned()), vec![])), - QualityItem::new(Mime(TopLevel::Image, SubLevel::Star, vec![]), q(0.8)), - QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.5))], + qitem(mime!(Image / ("svg+xml") )), + QualityItem::new(mime!(Image / _), q(0.8)), + QualityItem::new(mime!(_ / _), q(0.5))], // Substep 3 Type::Style => - vec![qitem(Mime(TopLevel::Text, SubLevel::Css, vec![])), - QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.1))], + vec![qitem(mime!(Text / Css)), + QualityItem::new(mime!(_ / _), q(0.1))], // Substep 1 - _ => vec![qitem(Mime(TopLevel::Star, SubLevel::Star, vec![]))] + _ => vec![qitem(mime!(_ / _))] }; // Substep 4 @@ -292,9 +292,7 @@ fn basic_fetch(request: Rc) -> Response { match url.non_relative_scheme_data() { Some(s) if &*s == "blank" => { let mut response = Response::new(); - response.headers.set(ContentType(Mime( - TopLevel::Text, SubLevel::Html, - vec![(Attr::Charset, Value::Utf8)]))); + response.headers.set(ContentType(mime!(Text / Html; Charset = Utf8))); *response.body.lock().unwrap() = ResponseBody::Done(vec![]); response }, diff --git a/components/net/lib.rs b/components/net/lib.rs index 2b008a89a32..dafb7f55c47 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -20,6 +20,8 @@ extern crate immeta; extern crate ipc_channel; #[macro_use] extern crate log; +#[macro_use] +extern crate mime; extern crate mime_guess; extern crate msg; extern crate net_traits; diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 7116af5ce78..4a782120ee1 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -1286,6 +1286,7 @@ dependencies = [ "immeta 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 2b9e4a2aea1..d89aad3ae69 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -1198,6 +1198,7 @@ dependencies = [ "immeta 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index e1a02fdcaa3..e7b83b55bfc 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -1180,6 +1180,7 @@ dependencies = [ "immeta 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1",