mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #6134 - Ms2ger:fetch, r=jdm
<!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6134) <!-- Reviewable:end -->
This commit is contained in:
commit
40dded8b3a
1 changed files with 12 additions and 12 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue