mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Rustfmt net_traits.
This commit is contained in:
parent
b76613a389
commit
b46846e2a0
9 changed files with 151 additions and 120 deletions
|
@ -15,7 +15,7 @@ lazy_static! {
|
|||
}
|
||||
|
||||
fn create_host_table() -> Option<HashMap<String, IpAddr>> {
|
||||
//TODO: handle bad file path
|
||||
// TODO: handle bad file path
|
||||
let path = match env::var("HOST_FILE") {
|
||||
Ok(host_file_path) => host_file_path,
|
||||
Err(_) => return None,
|
||||
|
@ -58,16 +58,18 @@ pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> {
|
|||
}
|
||||
|
||||
pub fn replace_hosts(url: &ServoUrl) -> ServoUrl {
|
||||
HOST_TABLE.lock().unwrap().as_ref().map_or_else(|| url.clone(), |host_table| {
|
||||
host_replacement(host_table, url)
|
||||
})
|
||||
HOST_TABLE.lock().unwrap().as_ref().map_or_else(|| url.clone(),
|
||||
|host_table| host_replacement(host_table, url))
|
||||
}
|
||||
|
||||
pub fn host_replacement(host_table: &HashMap<String, IpAddr>,
|
||||
url: &ServoUrl) -> ServoUrl {
|
||||
url.domain().and_then(|domain| host_table.get(domain).map(|ip| {
|
||||
let mut new_url = url.clone();
|
||||
new_url.set_ip_host(*ip).unwrap();
|
||||
new_url
|
||||
})).unwrap_or_else(|| url.clone())
|
||||
pub fn host_replacement(host_table: &HashMap<String, IpAddr>, url: &ServoUrl) -> ServoUrl {
|
||||
url.domain()
|
||||
.and_then(|domain| {
|
||||
host_table.get(domain).map(|ip| {
|
||||
let mut new_url = url.clone();
|
||||
new_url.set_ip_host(*ip).unwrap();
|
||||
new_url
|
||||
})
|
||||
})
|
||||
.unwrap_or_else(|| url.clone())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue