gecko-dev/servo/components/net_traits
Fernando Jiménez Moreno f6f72ddd13 servo: Merge #15783 - Replace manual host parsing code with parse-host crate (from ferjm:issue15756-parse-hosts); r=avadacatavra
This patch is replacing the code to parse the hosts file with the [parse-hosts](https://crates.io/crates/parse-hosts) crate. This crate has a [CC0 1.0 Universal License](https://creativecommons.org/publicdomain/zero/1.0/deed.en).

I could have used [HostsFile::load()](https://clarcharr.github.io/parse-hosts/parse_hosts/struct.HostsFile.html#method.load) directly, but this method loads `/etc/hosts` by default and does not allow to override the default path (for example with [env::var("HOST_FILE")](https://dxr.mozilla.org/servo/source/components/net_traits/hosts.rs#19)), so I kept the existing code to open and read the content of `env::var("HOST_FILE")` and also kept the [parse_hostsfile](https://dxr.mozilla.org/servo/source/components/net_traits/hosts.rs#42) method (used by the unit tests), but I modified it to use [HostsFile::read_buffered](https://clarcharr.github.io/parse-hosts/parse_hosts/struct.HostsFile.html#method.read_buffered), which is doing the actual hosts parsing for a given string buffer.

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15756 .
- [X] There are tests for these changes (tests/unit/net/resource_thread.rs and tests/unit/net/http_loader.rs)

Source-Repo: https://github.com/servo/servo
Source-Revision: 8f7c69e15f0b9beddad2ba67e3419f88aca0d579

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 1a04f0ca1484f93aa39e1f0d511a7b7d061e8afd
2017-03-09 17:17:14 -08:00
..
image servo: Merge #14831 - Rustfmt script_traits and net_traits (from servo:rustfmt-traits); r=nox 2017-01-03 08:11:09 -08:00
blob_url_store.rs servo: Merge #15300 - Remove unused part of the return value of parse_blob_url() (from servo:blob-fragment); r=Wafflespeanut 2017-01-30 06:21:46 -08:00
Cargo.toml servo: Merge #15783 - Replace manual host parsing code with parse-host crate (from ferjm:issue15756-parse-hosts); r=avadacatavra 2017-03-09 17:17:14 -08:00
filemanager_thread.rs servo: Merge #14831 - Rustfmt script_traits and net_traits (from servo:rustfmt-traits); r=nox 2017-01-03 08:11:09 -08:00
hosts.rs servo: Merge #15783 - Replace manual host parsing code with parse-host crate (from ferjm:issue15756-parse-hosts); r=avadacatavra 2017-03-09 17:17:14 -08:00
image_cache_thread.rs servo: Merge #14962 - Remove network requests from image cache thread (from jdm:image_script_load); r=Ms2ger,glennw,emilio 2017-02-22 17:50:48 -08:00
lib.rs servo: Merge #15783 - Replace manual host parsing code with parse-host crate (from ferjm:issue15756-parse-hosts); r=avadacatavra 2017-03-09 17:17:14 -08:00
net_error_list.rs servo: Merge #7053 - Move net_error_list from net to net_traits. Fixes #7050 (from connorimes:move-net-error-list); r=mbrubeck 2015-08-07 01:55:20 -06:00
pub_domains.rs servo: Merge #14831 - Rustfmt script_traits and net_traits (from servo:rustfmt-traits); r=nox 2017-01-03 08:11:09 -08:00
request.rs servo: Merge #15438 - Add ImmutableOrigin to allow for serializing origins (from asajeffrey:url-serializable-origin); r=jdm 2017-02-22 09:46:27 -08:00
response.rs servo: Merge #14868 - Fix loss of response type information in Fetch API (from bd339:iss14068); r=jdm 2017-01-09 18:36:38 -08:00
storage_thread.rs servo: Merge #14831 - Rustfmt script_traits and net_traits (from servo:rustfmt-traits); r=nox 2017-01-03 08:11:09 -08:00