aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/file_loader.rs
diff options
context:
space:
mode:
authorDavid Rajchenbach-Teller <D.O.Teller@gmail.com>2015-09-30 12:22:00 +0200
committerJosh Matthews <josh@joshmatthews.net>2015-12-31 07:45:03 -0500
commit1e81b8c13322deed21bdfea83b8a4f8c78b50e04 (patch)
treec994a88564692926b3e2dd07affd37b360b37738 /components/net/file_loader.rs
parent66c8aa8cdac24ad956be5e99be3b7bc07c5f798c (diff)
downloadservo-1e81b8c13322deed21bdfea83b8a4f8c78b50e04.tar.gz
servo-1e81b8c13322deed21bdfea83b8a4f8c78b50e04.zip
Resolves #4183 - Implemementing context-based MIME type sniffing
The version of the standard is not finalized at the time of this writing. Specifications may be found here: https://mimesniff.spec.whatwg.org/#context-specific-sniffing .
Diffstat (limited to 'components/net/file_loader.rs')
-rw-r--r--components/net/file_loader.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/components/net/file_loader.rs b/components/net/file_loader.rs
index 8b0a287c4a1..c2ab9cce9c7 100644
--- a/components/net/file_loader.rs
+++ b/components/net/file_loader.rs
@@ -61,6 +61,7 @@ pub fn factory(load_data: LoadData,
classifier: Arc<MIMEClassifier>,
cancel_listener: CancellationListener) {
let url = load_data.url;
+ let context = load_data.context;
assert!(&*url.scheme == "file");
spawn_named("file_loader".to_owned(), move || {
let file_path: Result<PathBuf, ()> = url.to_file_path();
@@ -77,7 +78,7 @@ pub fn factory(load_data: LoadData,
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);
+ classifier, &buf, context);
progress_chan.send(Payload(buf)).unwrap();
let read_result = read_all(reader, &progress_chan, &cancel_listener);
if let Ok(load_result) = read_result {
@@ -94,7 +95,8 @@ pub fn factory(load_data: LoadData,
if let Ok(chan) = start_sending_sniffed_opt(senders,
metadata,
classifier,
- &[]) {
+ &[],
+ context) {
let _ = chan.send(Done(Ok(())));
}
}
@@ -108,7 +110,7 @@ pub fn factory(load_data: LoadData,
// http://doc.rust-lang.org/std/fs/struct.OpenOptions.html#method.open
// but, we'll go for a "file not found!"
let url = Url::parse("about:not-found").unwrap();
- let load_data_404 = LoadData::new(url, None);
+ let load_data_404 = LoadData::new(context, url, None);
about_loader::factory(load_data_404, senders, classifier, cancel_listener)
}
}