servo: Merge #8609 - Add content_type to metadata in file_loader (from KiChjang:file-loader-headers); r=KiChjang

Fixes #4212.

Source-Repo: https://github.com/servo/servo
Source-Revision: ed6a3f5022ebfa364595b91d68b73e6ff60a4954
This commit is contained in:
Keith Yeung 2015-11-25 01:20:26 +05:01
Родитель acc0f49daf
Коммит b6f924158d
6 изменённых файлов: 36 добавлений и 2 удалений

Просмотреть файл

@ -44,6 +44,7 @@ rustc-serialize = "0.3"
cookie = "0.1"
regex = "0.1.14"
regex_macros = "0.1.8"
mime_guess = "1.1.1"
flate2 = "0.2.0"
uuid = "0.1.16"
euclid = {version = "0.3", features = ["plugins"]}

Просмотреть файл

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use mime_classifier::MIMEClassifier;
use mime_guess::guess_mime_type;
use net_traits::ProgressMsg::{Done, Payload};
use net_traits::{LoadConsumer, LoadData, Metadata};
use resource_task::{CancellationListener, ProgressSender};
@ -70,7 +71,9 @@ pub fn factory(load_data: LoadData,
}
match read_block(reader) {
Ok(ReadStatus::Partial(buf)) => {
let metadata = Metadata::default(url);
let mut metadata = Metadata::default(url);
let mime_type = guess_mime_type(file_path.as_path());
metadata.set_content_type(Some(&mime_type));
let progress_chan = start_sending_sniffed(senders, metadata,
classifier, &buf);
progress_chan.send(Payload(buf)).unwrap();
@ -83,7 +86,9 @@ pub fn factory(load_data: LoadData,
}
}
Ok(ReadStatus::EOF) => {
let metadata = Metadata::default(url);
let mut metadata = Metadata::default(url);
let mime_type = guess_mime_type(file_path.as_path());
metadata.set_content_type(Some(&mime_type));
if let Ok(chan) = start_sending_sniffed_opt(senders,
metadata,
classifier,

Просмотреть файл

@ -20,6 +20,7 @@ extern crate flate2;
extern crate brotli;
extern crate hyper;
extern crate ipc_channel;
extern crate mime_guess;
extern crate msg;
extern crate net_traits;
extern crate openssl;

9
servo/components/servo/Cargo.lock сгенерированный
Просмотреть файл

@ -1136,6 +1136,14 @@ dependencies = [
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mime_guess"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"mime 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "miniz-sys"
version = "0.1.6"
@ -1199,6 +1207,7 @@ dependencies = [
"hyper 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"mime_guess 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net_traits 0.0.1",
"openssl 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",

9
servo/ports/cef/Cargo.lock сгенерированный
Просмотреть файл

@ -1085,6 +1085,14 @@ dependencies = [
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mime_guess"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"mime 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "miniz-sys"
version = "0.1.6"
@ -1148,6 +1156,7 @@ dependencies = [
"hyper 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"mime_guess 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net_traits 0.0.1",
"openssl 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",

9
servo/ports/gonk/Cargo.lock сгенерированный
Просмотреть файл

@ -1065,6 +1065,14 @@ dependencies = [
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mime_guess"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"mime 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "miniz-sys"
version = "0.1.6"
@ -1128,6 +1136,7 @@ dependencies = [
"hyper 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"mime_guess 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net_traits 0.0.1",
"openssl 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",