Address PR comments

- Remove fn `url_is_local`
- Remove fn `set_local_urls_only`
- Fix `test_fetch_with_local_urls_only`
This commit is contained in:
Stjepan Glavina 2016-03-24 13:36:14 +01:00
parent 6576fde29b
commit 3ec4515a73
3 changed files with 12 additions and 17 deletions

View file

@ -110,8 +110,11 @@ fn main_fetch(request: Rc<Request>, cors_flag: bool, recursive_flag: bool) -> Re
let mut response = None;
// Step 2
if request.local_urls_only && !url_is_local(&request.current_url()) {
response = Some(Response::network_error());
if request.local_urls_only {
match &*request.current_url().scheme {
"about" | "blob" | "data" | "filesystem" => (), // Ok, the URL is local.
_ => response = Some(Response::network_error())
}
}
// Step 3
@ -1044,13 +1047,6 @@ fn includes_credentials(url: &Url) -> bool {
false
}
fn url_is_local(url: &Url) -> bool {
match &*url.scheme {
"about" | "blob" | "data" | "filesystem" => true,
_ => false
}
}
fn response_needs_revalidation(_response: &Response) -> bool {
// TODO this function
false

View file

@ -257,8 +257,4 @@ impl Request {
_ => false
}
}
pub fn set_local_urls_only(&mut self, local_urls_only: bool) {
self.local_urls_only = local_urls_only;
}
}

View file

@ -284,17 +284,20 @@ fn test_fetch_with_local_urls_only() {
request.referer = Referer::NoReferer;
// Set the flag.
request.set_local_urls_only(true);
request.local_urls_only = true;
let wrapped_request = Rc::new(request);
fetch(wrapped_request)
};
let local_url = Url::parse("about:config").unwrap();
assert!(do_fetch(local_url).is_network_error());
assert!(!do_fetch(server_url).is_network_error());
let local_url = Url::parse("about:blank").unwrap();
let local_response = do_fetch(local_url);
let server_response = do_fetch(server_url);
let _ = server.close();
assert!(!local_response.is_network_error());
assert!(server_response.is_network_error());
}
fn test_fetch_redirect_count(message: &'static [u8], redirect_cap: u32) -> Response {