feat: let consumers supply their own reqwest client to GitHubSource#7
Merged
Merged
Conversation
Add `GitHubSource::with_client(reqwest::Client)` so a consuming application can have the update's HTTP requests use its own client configuration — proxy, TLS, timeouts, a custom `User-Agent`, default auth headers, and so on — instead of the crate's internal default client. The crate's `User-Agent` now lives on the default client (built via `ClientBuilder::user_agent`) rather than being appended per request, so a caller-supplied client's own `User-Agent` is used as-is and never duplicated. The crate adds no `User-Agent` to a supplied client (the client should set one, as GitHub requires). Also re-export `reqwest` (`update_rs::reqwest`) so callers can name the exact `reqwest::Client` type `with_client` expects. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
GitHubSource::with_client(reqwest::Client)so a consuming application can make the update's HTTP requests use its own client configuration — proxy, TLS, timeouts, a customUser-Agent, default auth headers, etc. — instead of the crate's internal default client.This lets Git-Tool route self-update requests through a client carrying its own
Git-Tool/<version>User-Agent (and a single home for any future client config), rather than the crate's generic client.Changes
with_client(reqwest::Client)onGitHubSource— replaces the internal client wholesale.User-Agentmoves from a per-request.header(...)to the client level (ClientBuilder::user_agenton the default client). So a caller-supplied client's own UA is used as-is and never duplicated, and the crate forces no UA onto a supplied client (the client should set one — GitHub requires it). Default behaviour is unchanged: the default client still sendsSierraSoftworks/update-rs v<ver>.pub use reqwestso callers can name the exactreqwest::Clienttypewith_clientexpects (both crates already build against reqwest 0.12 with identical features, so types unify regardless, but this is the correct practice for a public API taking a reqwest type).Tests & CI
with_client-supplied client's UA is the one sent (proving no crate-forced/duplicated UA).fmt --check,clippy --all-targets --all-features -D warnings(and default),test(default /tracing/--all-features) → 37 + 5 doctests, anddoc --all-featureswith-D warnings.Additive, non-breaking. Suitable for a 0.5.0 release.
Follow-up
Once released, Git-Tool (git-tool#1885) will build a reqwest client with its
Git-Tool/<version>User-Agent and pass it viawith_clientin its updatemanager().🤖 Generated with Claude Code