Auto merge of #10154 - stjepang:fix-local-urls-only-10147, r=KiChjang

Fix #10147: Correctly handle flag local_urls_only

In function Request::fetch_main, flag local_urls_only (if set)
should allow fetching local urls only. Before this change, the flag had
the inverse behaviour.

Fixes #10147.
Test with: `./mach test-unit -p net fetch::test_fetch_with_local_urls_only`

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10154)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-03-25 12:42:48 +05:30
commit 38e8c923b5
3 changed files with 36 additions and 4 deletions

View file

@ -112,9 +112,9 @@ fn main_fetch(request: Rc<Request>, cors_flag: bool, recursive_flag: bool) -> Re
// Step 2
if request.local_urls_only {
match &*request.current_url().scheme {
"about" | "blob" | "data" | "filesystem" => response = Some(Response::network_error()),
_ => { }
};
"about" | "blob" | "data" | "filesystem" => (), // Ok, the URL is local.
_ => response = Some(Response::network_error())
}
}
// Step 3

View file

@ -152,7 +152,7 @@ impl Request {
pub fn new(url: Url,
origin: Option<Origin>,
is_service_worker_global_scope: bool) -> Request {
Request {
Request {
method: RefCell::new(Method::Get),
local_urls_only: false,
sandboxed_storage_area_urls: false,