mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Introduce HstsList::switch_known_hsts_host_domain_url_to_https
This commit is contained in:
parent
170bcfc03e
commit
fb86bfebf4
3 changed files with 18 additions and 9 deletions
|
@ -6,6 +6,7 @@ use net_traits::IncludeSubdomains;
|
|||
use net_traits::pub_domains::reg_suffix;
|
||||
use serde_json;
|
||||
use servo_config::resource_files::read_resource_file;
|
||||
use servo_url::ServoUrl;
|
||||
use std::collections::HashMap;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
use std::str::from_utf8;
|
||||
|
@ -134,4 +135,14 @@ impl HstsList {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Step 10 of https://fetch.spec.whatwg.org/#concept-main-fetch.
|
||||
pub fn switch_known_hsts_host_domain_url_to_https(&self, url: &mut ServoUrl) {
|
||||
if url.scheme() != "http" {
|
||||
return;
|
||||
}
|
||||
if url.domain().map_or(false, |domain| self.is_host_secure(domain)) {
|
||||
url.as_mut_url().set_scheme("https").unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue