mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-22 02:09:28 +00:00
servo: Merge #8650 - Redirect to an error page on 404! (from Wafflespeanut:about-404); r=Wafflespeanut
fixes #7658 Source-Repo: https://github.com/servo/servo Source-Revision: 831979d6a7e6fc615434a6585710b2becb7dbf42
This commit is contained in:
parent
0619875813
commit
21b9b579d7
@ -19,7 +19,9 @@ pub fn factory(mut load_data: LoadData,
|
||||
start_chan: LoadConsumer,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
cancel_listener: CancellationListener) {
|
||||
match load_data.url.non_relative_scheme_data().unwrap() {
|
||||
let url = load_data.url.clone();
|
||||
let non_relative_scheme_data = url.non_relative_scheme_data().unwrap();
|
||||
match non_relative_scheme_data {
|
||||
"blank" => {
|
||||
let metadata = Metadata {
|
||||
final_url: load_data.url,
|
||||
@ -34,9 +36,10 @@ pub fn factory(mut load_data: LoadData,
|
||||
return
|
||||
}
|
||||
"crash" => panic!("Loading the about:crash URL."),
|
||||
"failure" => {
|
||||
"failure" | "not-found" => {
|
||||
let mut path = resources_dir_path();
|
||||
path.push("failure.html");
|
||||
let file_name = non_relative_scheme_data.to_owned() + ".html";
|
||||
path.push(&file_name);
|
||||
assert!(path.exists());
|
||||
load_data.url = Url::from_file_path(&*path).unwrap();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use about_loader;
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use mime_guess::guess_mime_type;
|
||||
use net_traits::ProgressMsg::{Done, Payload};
|
||||
@ -14,6 +15,7 @@ use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use url::Url;
|
||||
use util::task::spawn_named;
|
||||
|
||||
static READ_SIZE: usize = 8192;
|
||||
@ -101,8 +103,13 @@ pub fn factory(load_data: LoadData,
|
||||
}
|
||||
};
|
||||
}
|
||||
Err(e) => {
|
||||
send_error(url, e.description().to_owned(), senders);
|
||||
Err(_) => {
|
||||
// this should be one of the three errors listed in
|
||||
// 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);
|
||||
about_loader::factory(load_data_404, senders, classifier, cancel_listener)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
servo/resources/not-found.html
Normal file
9
servo/resources/not-found.html
Normal file
@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>about:not-found</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- courtesy of https://mozillians.org/blahblah -->
|
||||
<img src="tumbeast.png">
|
||||
</body>
|
||||
</html>
|
BIN
servo/resources/tumbeast.png
Normal file
BIN
servo/resources/tumbeast.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 78 KiB |
Loading…
x
Reference in New Issue
Block a user