-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port from reqwest to ureq #205
Conversation
Thanks for this @TomFryersMidsummer! As I note in the issue, I don't consider the proj network use case as requiring async http, so reqwest was not a conscious choice and I'm happy to see it replaced. |
src/network.rs
Outdated
res.into_reader() | ||
.take(size_to_read as u64) | ||
.read_to_end(&mut buf) | ||
.map_err(|_| ProjError::ReadError)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should propagate the error here, like for NetworkError
.
#[cfg(feature = "network")] | ||
BuilderError(#[from] reqwest::Error), | ||
NetworkError(Box<ureq::Error>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's mark ProjError
as #[non_exhaustive]
, so we don't take a breaking change next time we add a variant.
// Copy the downloaded bytes into the buffer so it can be passed around | ||
let capacity = contentlength.min(size_to_read); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pre-existing issue, but we aren't consistent about out_size_read
. If Content-Length
is larger than size_to_read
, we set out_size_read
to a value larger than the actual length of the buffer. We should just set it to buf.len()
, regardless or how we handle that case.
Same for _network_open
of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some nits.
I'm not convinced that ureq
is the better choice, long-term (vs. reqwest
or isaahc
/ libcurl
), but I guess it's pretty easy to revert in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I agree with @lnicola's feedback as well.
@@ -19,7 +19,7 @@ geo-types = { version = "0.7.10", optional = true } | |||
libc = "0.2.119" | |||
num-traits = "0.2.14" | |||
thiserror = "1.0.30" | |||
reqwest = { version = "0.12.0", optional = true, default-features = false, features = ["blocking", "rustls-tls"] } | |||
ureq = { version = "2.0.0", optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you actually test this on 2.0.0? Otherwise please specify whatever version you tested on (latest is 2.9.7).
Otherwise it's hard to know if you are leveraging any functionality that was added in a minor release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I tested it on 2.0.0.
Thank you for the feedback. I believe I've addressed everything now |
I believe |
Yes, sorry – missed that. I’ve fixed it now. |
Looks good, at least looking at the new commits, but I'll let someone else merge it since I've never used this crate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer reqwest
over ureq
but I also don't use this feature of proj
and hope we can just remove it someday soooo here's a ✅
The network feature? Hard to imagine it going anywhere: the grid download functionality is a big step forward; without it you have to ship a couple of hundred MBs around with every libproj (which we wouldn't be able to do bc of crates.io limitations, even if we wanted to), and older versions have out-of-date grids leading to less-accurate conversions etc. |
Oops maybe I'm mixing up the network functionality in a different crate, disregard! |
Addresses georust#189, reducing `cargo tree -F network | wc -l` from 296 to 190.
Addresses #189, reducing
cargo tree -F network | wc -l
from 296 to 190.