aboutsummaryrefslogtreecommitdiffstats
path: root/components/net
diff options
context:
space:
mode:
Diffstat (limited to 'components/net')
-rw-r--r--components/net/hosts.rs17
-rw-r--r--components/net/http_loader.rs5
2 files changed, 5 insertions, 17 deletions
diff --git a/components/net/hosts.rs b/components/net/hosts.rs
index 768108052e7..06e58fab3b9 100644
--- a/components/net/hosts.rs
+++ b/components/net/hosts.rs
@@ -16,22 +16,13 @@ lazy_static! {
}
fn create_host_table() -> Option<HashMap<String, IpAddr>> {
- // TODO: handle bad file path
- let path = match env::var("HOST_FILE") {
- Ok(host_file_path) => host_file_path,
- Err(_) => return None,
- };
+ let path = env::var_os("HOST_FILE")?;
- let mut file = match File::open(&path) {
- Ok(f) => BufReader::new(f),
- Err(_) => return None,
- };
+ let file = File::open(&path).ok()?;
+ let mut reader = BufReader::new(file);
let mut lines = String::new();
- match file.read_to_string(&mut lines) {
- Ok(_) => (),
- Err(_) => return None,
- };
+ reader.read_to_string(&mut lines).ok()?;
Some(parse_hostsfile(&lines))
}
diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs
index e3972f6c0f3..c7b15d785ed 100644
--- a/components/net/http_loader.rs
+++ b/components/net/http_loader.rs
@@ -108,10 +108,7 @@ impl WrappedHttpResponse {
}
fn content_encoding(&self) -> Option<Encoding> {
- let encodings = match self.headers().get::<ContentEncoding>() {
- Some(&ContentEncoding(ref encodings)) => encodings,
- None => return None,
- };
+ let &ContentEncoding(ref encodings) = self.headers().get()?;
if encodings.contains(&Encoding::Gzip) {
Some(Encoding::Gzip)
} else if encodings.contains(&Encoding::Deflate) {