create about_loader, handle about:blank

This commit is contained in:
Sean McArthur 2014-09-04 22:31:28 -07:00
parent b8b51b6dd8
commit 523445c865
10 changed files with 64 additions and 27 deletions

View file

@ -4,13 +4,13 @@
//! A task that takes a URL and streams back the binary data.
use about_loader;
use data_loader;
use file_loader;
use http_loader;
use data_loader;
use std::comm::{channel, Receiver, Sender};
use std::task::TaskBuilder;
use std::os;
use http::headers::content_type::MediaType;
use ResponseHeaderCollection = http::headers::response::HeaderCollection;
use RequestHeaderCollection = http::headers::request::HeaderCollection;
@ -201,29 +201,12 @@ impl ResourceManager {
}
}
fn load(&self, mut load_data: LoadData, start_chan: Sender<LoadResponse>) {
fn load(&self, load_data: LoadData, start_chan: Sender<LoadResponse>) {
let loader = match load_data.url.scheme.as_slice() {
"file" => file_loader::factory,
"http" | "https" => http_loader::factory,
"data" => data_loader::factory,
"about" => {
match load_data.url.non_relative_scheme_data().unwrap() {
"crash" => fail!("Loading the about:crash URL."),
"failure" => {
// FIXME: Find a way to load this without relying on the `../src` directory.
let mut path = os::self_exe_path().expect("can't get exe path");
path.pop();
path.push_many(["src", "test", "html", "failure.html"]);
load_data.url = Url::from_file_path(&path).unwrap();
file_loader::factory
}
_ => {
start_sending(start_chan, Metadata::default(load_data.url))
.send(Done(Err("Unknown about: URL.".to_string())));
return
}
}
},
"about" => about_loader::factory,
_ => {
debug!("resource_task: no loader for scheme {:s}", load_data.url.scheme);
start_sending(start_chan, Metadata::default(load_data.url))