From a66f1868661e14975aa6583062a698ff3b5c8952 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 20 Oct 2016 08:13:19 +0200 Subject: [PATCH] Return a network error Response from http_network_fetch when obtain_response fails. --- components/net/fetch/methods.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 4518c3b7cf7..aac309b5ecf 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -28,8 +28,7 @@ use net_traits::{FetchTaskTarget, FetchMetadata, NetworkError}; use net_traits::request::{CacheMode, CredentialsMode, Destination}; use net_traits::request::{RedirectMode, Referrer, Request, RequestMode, ResponseTainting}; use net_traits::request::{Type, Origin, Window}; -use net_traits::response::{HttpsState, TerminationReason}; -use net_traits::response::{Response, ResponseBody, ResponseType}; +use net_traits::response::{HttpsState, Response, ResponseBody, ResponseType}; use resource_thread::CancellationListener; use std::borrow::Cow; use std::collections::HashSet; @@ -1099,8 +1098,14 @@ fn http_network_fetch(request: Rc, } }); }, - Err(_) => { - response.termination_reason = Some(TerminationReason::Fatal); + Err(error) => { + let error = match error.error { + LoadErrorType::ConnectionAborted { .. } => unreachable!(), + LoadErrorType::Ssl { reason } => NetworkError::SslValidation(error.url, reason), + LoadErrorType::Cancelled => NetworkError::LoadCancelled, + e => NetworkError::Internal(e.description().to_owned()) + }; + return Response::network_error(error); } };