mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
net: Treat SSL handshake errors differently from other hyper errors.
This commit is contained in:
parent
cb4e3cb16a
commit
b7a640b517
2 changed files with 9 additions and 4 deletions
|
@ -712,12 +712,17 @@ pub enum NetworkError {
|
||||||
Internal(String),
|
Internal(String),
|
||||||
LoadCancelled,
|
LoadCancelled,
|
||||||
/// SSL validation error that has to be handled in the HTML parser
|
/// SSL validation error that has to be handled in the HTML parser
|
||||||
SslValidation(ServoUrl, String),
|
SslValidation(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NetworkError {
|
impl NetworkError {
|
||||||
pub fn from_hyper_error(error: &HyperError) -> Self {
|
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 {
|
pub fn from_http_error(error: &HttpError) -> Self {
|
||||||
|
|
|
@ -731,9 +731,9 @@ impl FetchResponseListener for ParserContext {
|
||||||
FetchMetadata::Unfiltered(m) => m,
|
FetchMetadata::Unfiltered(m) => m,
|
||||||
FetchMetadata::Filtered { unsafe_, .. } => unsafe_,
|
FetchMetadata::Filtered { unsafe_, .. } => unsafe_,
|
||||||
}),
|
}),
|
||||||
Err(NetworkError::SslValidation(url, reason)) => {
|
Err(NetworkError::SslValidation(reason)) => {
|
||||||
ssl_error = Some(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();
|
let mime: Option<Mime> = "text/html".parse().ok();
|
||||||
meta.set_content_type(mime.as_ref());
|
meta.set_content_type(mime.as_ref());
|
||||||
Some(meta)
|
Some(meta)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue