Skip to content
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

Merged
merged 5 commits into from
Jun 13, 2024
Merged

Port from reqwest to ureq #205

merged 5 commits into from
Jun 13, 2024

Conversation

TomFryersMidsummer
Copy link
Contributor

Addresses #189, reducing cargo tree -F network | wc -l from 296 to 190.

@urschrei
Copy link
Member

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)?;
Copy link
Member

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>),
Copy link
Member

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);
Copy link
Member

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.

Copy link
Member

@lnicola lnicola left a 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.

Copy link
Member

@michaelkirk michaelkirk left a 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 }
Copy link
Member

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.

Copy link
Contributor Author

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.

@TomFryersMidsummer
Copy link
Contributor Author

Thank you for the feedback. I believe I've addressed everything now

@lnicola
Copy link
Member

lnicola commented Jun 13, 2024

I believe _network_read_range still returns the Content-Lengt instead of the actual size of the data.

@TomFryersMidsummer
Copy link
Contributor Author

Yes, sorry – missed that. I’ve fixed it now.

@lnicola
Copy link
Member

lnicola commented Jun 13, 2024

Looks good, at least looking at the new commits, but I'll let someone else merge it since I've never used this crate.

Copy link
Member

@frewsxcv frewsxcv left a 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 ✅

@frewsxcv frewsxcv added this pull request to the merge queue Jun 13, 2024
Merged via the queue into georust:main with commit 86b2124 Jun 13, 2024
28 checks passed
@urschrei
Copy link
Member

I also don't use this feature of proj and hope we can just remove it someday

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.

@frewsxcv
Copy link
Member

Oops maybe I'm mixing up the network functionality in a different crate, disregard!

urschrei pushed a commit to kylebarron/proj that referenced this pull request Jul 1, 2024
Addresses georust#189, reducing `cargo tree -F network | wc -l` from 296 to
190.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants