Make Response::internal_response a bare boolean

This commit is contained in:
Anthony Ramine 2017-04-01 12:17:38 +02:00
parent cb2eb81208
commit 80e02303d3
2 changed files with 12 additions and 12 deletions

View file

@ -553,15 +553,15 @@ pub fn http_fetch(request: &mut Request,
request.skip_service_worker = true;
// Substep 3
let fetch_result = http_network_or_cache_fetch(request, authentication_fetch_flag,
cors_flag, done_chan, context);
let mut fetch_result = http_network_or_cache_fetch(
request, authentication_fetch_flag, cors_flag, done_chan, context);
// Substep 4
if cors_flag && cors_check(&request, &fetch_result).is_err() {
return Response::network_error(NetworkError::Internal("CORS check failed".into()));
}
fetch_result.return_internal.set(false);
fetch_result.return_internal = false;
response = Some(fetch_result);
}
@ -579,7 +579,7 @@ pub fn http_fetch(request: &mut Request,
},
RedirectMode::Follow => {
// set back to default
response.return_internal.set(true);
response.return_internal = true;
http_redirect_fetch(request, cache, response,
cors_flag, target, done_chan, context)
}
@ -642,7 +642,7 @@ pub fn http_fetch(request: &mut Request,
}
// set back to default
response.return_internal.set(true);
response.return_internal = true;
// Step 7
response
}
@ -657,7 +657,7 @@ fn http_redirect_fetch(request: &mut Request,
context: &FetchContext)
-> Response {
// Step 1
assert_eq!(response.return_internal.get(), true);
assert!(response.return_internal);
// Step 2
if !response.actual_response().headers.has::<Location>() {

View file

@ -10,7 +10,7 @@ use hyper::status::StatusCode;
use hyper_serde::Serde;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::cell::{Cell, RefCell};
use std::cell::RefCell;
use std::sync::{Arc, Mutex};
/// [Response type](https://fetch.spec.whatwg.org/#concept-response-type)
@ -97,7 +97,7 @@ pub struct Response {
/// is a filtered response
pub internal_response: Option<Box<Response>>,
/// whether or not to try to return the internal_response when asked for actual_response
pub return_internal: Cell<bool>,
pub return_internal: bool,
}
impl Response {
@ -115,7 +115,7 @@ impl Response {
https_state: HttpsState::None,
referrer: None,
internal_response: None,
return_internal: Cell::new(true),
return_internal: true,
}
}
@ -133,7 +133,7 @@ impl Response {
https_state: HttpsState::None,
referrer: None,
internal_response: None,
return_internal: Cell::new(true),
return_internal: true,
}
}
@ -156,7 +156,7 @@ impl Response {
}
pub fn actual_response(&self) -> &Response {
if self.return_internal.get() && self.internal_response.is_some() {
if self.return_internal && self.internal_response.is_some() {
&**self.internal_response.as_ref().unwrap()
} else {
self
@ -164,7 +164,7 @@ impl Response {
}
pub fn to_actual(self) -> Response {
if self.return_internal.get() && self.internal_response.is_some() {
if self.return_internal && self.internal_response.is_some() {
*self.internal_response.unwrap()
} else {
self