mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Add content_type to metadata in file_loader
This commit is contained in:
parent
a5babb89a0
commit
af705a6faf
6 changed files with 36 additions and 2 deletions
|
@ -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
components/servo/Cargo.lock
generated
9
components/servo/Cargo.lock
generated
|
@ -1119,6 +1119,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"
|
||||
|
@ -1182,6 +1190,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
ports/cef/Cargo.lock
generated
9
ports/cef/Cargo.lock
generated
|
@ -1071,6 +1071,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"
|
||||
|
@ -1134,6 +1142,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
ports/gonk/Cargo.lock
generated
9
ports/gonk/Cargo.lock
generated
|
@ -1051,6 +1051,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"
|
||||
|
@ -1114,6 +1122,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)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue