servo: Merge #6134 - Cleanup the fetch code (from Ms2ger:fetch); r=jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: 40dded8b3a2e9eb9c0f0b7af189df27f3ad6414a
This commit is contained in:
Ms2ger 2015-05-19 12:13:37 -05:00
Родитель 137ee1c88c
Коммит e29f24a0f3
1 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -114,7 +114,7 @@ pub struct Request {
}
impl Request {
pub fn new(url: Url, context: Context, isServiceWorkerGlobalScope: bool) -> Request {
pub fn new(url: Url, context: Context, is_service_worker_global_scope: bool) -> Request {
Request {
method: Method::Get,
url: url,
@ -122,7 +122,7 @@ impl Request {
unsafe_request: false,
body: None,
preserve_content_codings: false,
is_service_worker_global_scope: isServiceWorkerGlobalScope,
is_service_worker_global_scope: is_service_worker_global_scope,
skip_service_worker: false,
context: context,
context_frame_type: ContextFrameType::ContextNone,
@ -263,14 +263,14 @@ impl Request {
if !response.headers.has::<Location>() {
return response;
}
let location = response.headers.get::<Location>();
if location.is_none() {
return Response::network_error();
}
let location = match response.headers.get::<Location>() {
None => return Response::network_error(),
Some(location) => location,
};
// Step 5
let locationUrl = Url::parse(location.unwrap());
let location_url = Url::parse(location);
// Step 6
let locationUrl = match locationUrl {
let location_url = match location_url {
Ok(url) => url,
Err(_) => return Response::network_error()
};
@ -286,10 +286,10 @@ impl Request {
if self.redirect_mode == RedirectMode::Follow {
// FIXME: Origin method of the Url crate hasn't been implemented (https://github.com/servo/rust-url/issues/54)
// Substep 1
// if cors_flag && locationUrl.origin() != self.url.origin() { self.origin = None; }
// if cors_flag && location_url.origin() != self.url.origin() { self.origin = None; }
// Substep 2
if cors_flag && (!locationUrl.username().unwrap_or("").is_empty() ||
locationUrl.password().is_some()) {
if cors_flag && (!location_url.username().unwrap_or("").is_empty() ||
location_url.password().is_some()) {
return Response::network_error();
}
// Substep 3
@ -299,7 +299,7 @@ impl Request {
self.method = Method::Get;
}
// Substep 4
self.url = locationUrl;
self.url = location_url;
// Substep 5
return self.fetch(cors_flag);
}