Initialize without error when `/etc/resolv.conf` is missing
Some restricted environments may not have /etc/resolv.conf, to keep things simple and reduce entropy. The latter reason is why Nix doesn't provide one in its (offline) sandbox.
By allowing initialization to continue in this circumstance, it is possible for programs that use reqwest to keep their state simple, while allowing to be run in such restricted environments.
The error from the missing file seems to be propagated through here: https://github.com/seanmonstar/reqwest/blob/6792f697fcdb27c47dcbf7bd05f23368d1d4ac80/src/dns/trust_dns.rs#L56
Cases where this is useful include
- https://github.com/lycheeverse/lychee/issues/1303
- Nix builds that run tests of Rust programs that use reqwest
Would it be acceptable to simply continue with an empty config if the system resolv.conf is missing?
Should it print a warning in that case?
Or should this behavior by opt-in, configured by the caller somehow? Is the library designed so that the resolver is pluggable?
Yes, reqwest allows for custom resolvers