mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Auto merge of #8609 - KiChjang:file-loader-headers, r=KiChjang
Add content_type to metadata in file_loader Fixes #4212. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8609) <!-- Reviewable:end -->
This commit is contained in:
commit
ed6a3f5022
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
|
@ -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
ports/cef/Cargo.lock
generated
9
ports/cef/Cargo.lock
generated
|
@ -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
ports/gonk/Cargo.lock
generated
9
ports/gonk/Cargo.lock
generated
|
@ -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)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue