mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Update parse-hosts.
This commit is contained in:
parent
ba2a6c1727
commit
d86fa9d25b
2 changed files with 5 additions and 14 deletions
|
@ -28,7 +28,7 @@ mime_guess = "1.8.0"
|
|||
msg = {path = "../msg"}
|
||||
net_traits = {path = "../net_traits"}
|
||||
openssl = "0.9"
|
||||
parse-hosts = "0.3.0"
|
||||
parse-hosts = "0.4.0"
|
||||
profile_traits = {path = "../profile_traits"}
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
|
|
@ -41,19 +41,10 @@ pub fn replace_host_table(table: HashMap<String, IpAddr>) {
|
|||
}
|
||||
|
||||
pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> {
|
||||
let mut host_table = HashMap::new();
|
||||
|
||||
for line in HostsFile::read_buffered(hostsfile_content.as_bytes()).lines() {
|
||||
if let Ok(ref line) = line {
|
||||
for host in line.hosts() {
|
||||
if let Some(ip) = line.ip() {
|
||||
host_table.insert(host.to_owned(), ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
host_table
|
||||
HostsFile::read_buffered(hostsfile_content.as_bytes())
|
||||
.pairs()
|
||||
.filter_map(Result::ok)
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn replace_host(host: &str) -> Cow<str> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue