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

Replace reqwest with ureq #417

Merged
merged 2 commits into from
Mar 9, 2025
Merged

Replace reqwest with ureq #417

merged 2 commits into from
Mar 9, 2025

Conversation

erickguan
Copy link
Contributor

ureq is a blocking HTTP client. ureq is simpler than reqwest. This brings:

  • smaller binary size
  • cleaner configuration interfaces

Fixes #415

ureq is a blocking HTTP client. ureq is simpler than reqwest. This
brings:
- smaller binary size
- cleaner configuration interfaces
Copy link
Collaborator

@niklasmohrin niklasmohrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

src/cache.rs Outdated
Comment on lines 436 to 443
if let Ok(ref host) = env::var("HTTP_PROXY") {
return Ok(Some(Proxy::new(host)?));
}
if let Ok(ref host) = env::var("HTTPS_PROXY") {
return Ok(Some(Proxy::new(host)?));
}

Ok(None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is different from what we did before. The code before uses HTTP_PROXY as a Proxy::http and HTTPS_PROXY as a Proxy::https, which means that they will be used for http and https traffic respectively (see https://docs.rs/reqwest/latest/reqwest/struct.Proxy.html). Now, this uses HTTP_PROXY also for https traffic if present and ignores HTTP_PROXY.

If we want to be conservative, we could only check HTTPS_PROXY. Alternatively, there is https://docs.rs/ureq/latest/ureq/struct.Proxy.html#method.try_from_env, which would prefer HTTPS_PROXY, but still use HTTP_PROXY if HTTPS_PROXY is unset. I am not sure which approach is best

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My experience is to set both HTTP_PROXY/HTTPS_PROXY. Otherwise, I will go with SOCKS_PROXY. The default preference looks okay. HTTP_PROXY is also not going to affect tldr given the source is usually GitHub. And GitHub uses https.

Let's go with the default which will use Proxy::try_from_env.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. We should add a test at some point, see #418

@erickguan erickguan requested a review from niklasmohrin March 1, 2025 21:23
Copy link
Collaborator

@niklasmohrin niklasmohrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, thanks!

@niklasmohrin niklasmohrin merged commit 3d8d488 into tealdeer-rs:main Mar 9, 2025
9 checks passed
@erickguan erickguan deleted the ureq branch March 9, 2025 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Consider replacing reqwest with ureq
2 participants