mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Move about: URL handling from parsing to loading. Fix #1094
This commit is contained in:
parent
709504e1f9
commit
609762ac63
2 changed files with 21 additions and 17 deletions
|
@ -10,6 +10,7 @@ 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;
|
||||
|
@ -202,15 +203,33 @@ impl ResourceManager {
|
|||
}
|
||||
}
|
||||
|
||||
fn load(&self, load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
||||
fn load(&self, mut load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
||||
let loader = match load_data.url.scheme.as_slice() {
|
||||
"file" => file_loader::factory(),
|
||||
"http" => 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
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
debug!("resource_task: no loader for scheme {:s}", load_data.url.scheme);
|
||||
start_sending(start_chan, Metadata::default(load_data.url))
|
||||
.send(Done(Err("no loader for scheme".to_string())));
|
||||
.send(Done(Err("no loader for scheme".to_string())));
|
||||
return
|
||||
}
|
||||
};
|
||||
|
|
|
@ -42,21 +42,6 @@ pub fn try_parse_url(str_url: &str, base_url: Option<Url>) -> Result<Url, &'stat
|
|||
},
|
||||
Ok(url) => {
|
||||
match (url.scheme.as_slice(), url.scheme_data.clone()) {
|
||||
("about", rust_url::OtherSchemeData(scheme_data)) => {
|
||||
match scheme_data.as_slice() {
|
||||
"crash" => {
|
||||
fail!("about:crash");
|
||||
}
|
||||
"failure" => {
|
||||
let mut path = os::self_exe_path().expect("can't get exe path");
|
||||
path.push("../src/test/html/failure.html");
|
||||
// FIXME (#1094): not the right way to transform a path
|
||||
format!("file://{}", path.display().to_str())
|
||||
}
|
||||
// TODO: handle the rest of the about: pages
|
||||
_ => str_url.to_string()
|
||||
}
|
||||
},
|
||||
("data", _) => {
|
||||
// Drop whitespace within data: URLs, e.g. newlines within a base64
|
||||
// src="..." block. Whitespace intended as content should be
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue