Skip to content

feat: let consumers supply their own reqwest client to GitHubSource#7

Merged
notheotherben merged 1 commit into
mainfrom
feature/injectable-http-client
Jun 21, 2026
Merged

feat: let consumers supply their own reqwest client to GitHubSource#7
notheotherben merged 1 commit into
mainfrom
feature/injectable-http-client

Conversation

@notheotherben

Copy link
Copy Markdown
Member

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 custom User-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) on GitHubSource — replaces the internal client wholesale.
  • The crate's User-Agent moves from a per-request .header(...) to the client level (ClientBuilder::user_agent on 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 sends SierraSoftworks/update-rs v<ver>.
  • pub use reqwest so callers can name the exact reqwest::Client type with_client expects (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

  • Two new tests (wiremock-based) assert the default client sends the crate's UA, and that a with_client-supplied client's UA is the one sent (proving no crate-forced/duplicated UA).
  • Green locally across every gate: fmt --check, clippy --all-targets --all-features -D warnings (and default), test (default / tracing / --all-features) → 37 + 5 doctests, and doc --all-features with -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 via with_client in its update manager().

🤖 Generated with Claude Code

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>
@notheotherben notheotherben merged commit f5d568d into main Jun 21, 2026
5 checks passed
@notheotherben notheotherben deleted the feature/injectable-http-client branch June 21, 2026 16:09
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.

1 participant