Make Response::url private.

This commit is contained in:
Ms2ger 2016-11-07 10:17:29 +01:00
parent c1e1695f66
commit 15b55c3231
3 changed files with 7 additions and 3 deletions

View file

@ -687,7 +687,7 @@ fn http_redirect_fetch<UI: 'static + UIProvider>(request: Rc<Request>,
Some(&Location(ref location)) => location.clone(),
_ => return Response::network_error(NetworkError::Internal("Location header parsing failure".into()))
};
let response_url = response.actual_response().url.as_ref().unwrap();
let response_url = response.actual_response().url().unwrap();
let location_url = response_url.join(&*location);
let location_url = match location_url {
Ok(url) => url,

View file

@ -79,7 +79,7 @@ pub enum ResponseMsg {
pub struct Response {
pub response_type: ResponseType,
pub termination_reason: Option<TerminationReason>,
pub url: Option<Url>,
url: Option<Url>,
pub url_list: RefCell<Vec<Url>>,
/// `None` can be considered a StatusCode of `0`.
#[ignore_heap_size_of = "Defined in hyper"]
@ -136,6 +136,10 @@ impl Response {
}
}
pub fn url(&self) -> Option<&Url> {
self.url.as_ref()
}
pub fn is_network_error(&self) -> bool {
match self.response_type {
ResponseType::Error(..) => true,

View file

@ -383,8 +383,8 @@ fn test_fetch_response_is_opaque_filtered() {
assert!(!fetch_response.is_network_error());
assert_eq!(fetch_response.response_type, ResponseType::Opaque);
assert!(fetch_response.url().is_none());
assert!(fetch_response.url_list.into_inner().len() == 0);
assert!(fetch_response.url.is_none());
// this also asserts that status message is "the empty byte sequence"
assert!(fetch_response.status.is_none());
assert_eq!(fetch_response.headers, Headers::new());