Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add api module with
download_to
method
Use the `ureq` crate for simple synchronous requests, but keep it encapsulated so we can replace it later if need be. Create an agent that supports proxies and require HTTPS for all requests. Use it in the `download_to` method, but if the API base URL has a `file` schema, skip the ureq agent and copy the file directly. This will be useful for working with `rsync`d mirrors. Add variants to the BuildError enum for IO, URL parsing and formatting, and HTTP request errors from ureq. Box ureq errors because otherwise they're far to big, and [clippy complains] about the error size. Make a custom File error to improve IO errors to include the action attempted and relevant file name or names. Use `httpmock` to test the handling of `http:` URLs, and `sha2` & `tempfile` to test `file:` URLs. While at it, exclude `Cargo.lock` from `git diff`; it's just too verbose and distracting. Also use string comparison for some error tests in `src/tests.rs`. [clippy complains]: https://rust-lang.github.io/rust-clippy/master/index.html#result_large_errclippyClick
- Loading branch information