net: Treat SSL handshake errors differently from other hyper errors.

This commit is contained in:
Josh Matthews 2020-05-27 19:22:46 -04:00
parent cb4e3cb16a
commit b7a640b517
2 changed files with 9 additions and 4 deletions

View file

@ -712,12 +712,17 @@ pub enum NetworkError {
Internal(String),
LoadCancelled,
/// SSL validation error that has to be handled in the HTML parser
SslValidation(ServoUrl, String),
SslValidation(String),
}
impl NetworkError {
pub fn from_hyper_error(error: &HyperError) -> Self {
NetworkError::Internal(error.to_string())
let s = error.to_string();
if s.contains("the handshake failed") {
NetworkError::SslValidation(s)
} else {
NetworkError::Internal(s)
}
}
pub fn from_http_error(error: &HttpError) -> Self {

View file

@ -731,9 +731,9 @@ impl FetchResponseListener for ParserContext {
FetchMetadata::Unfiltered(m) => m,
FetchMetadata::Filtered { unsafe_, .. } => unsafe_,
}),
Err(NetworkError::SslValidation(url, reason)) => {
Err(NetworkError::SslValidation(reason)) => {
ssl_error = Some(reason);
let mut meta = Metadata::default(url);
let mut meta = Metadata::default(self.url.clone());
let mime: Option<Mime> = "text/html".parse().ok();
meta.set_content_type(mime.as_ref());
Some(meta)