refactor: centralize User-Agent header via shared httputil package#79
Merged
steve-calvert-glean merged 1 commit intomainfrom Apr 6, 2026
Merged
Conversation
Add internal/httputil package that owns the CLI version string and provides NewHTTPClient/NewTransport to inject User-Agent on all outbound HTTP requests. Previously only SDK and streaming chat requests set the header; auth discovery, domain lookup, update checks, and the api command did not. - NewTransport wraps any RoundTripper with UA injection + optional extra headers via WithHeader option - Eliminates cliTransport from internal/client (X-Glean-Auth-Type now handled via httputil.WithHeader) - Removes duplicated SetVersion/Version from internal/client - Migrates all 7 HTTP call sites to use the shared factory Co-Authored-By: Claude Opus 4.6 <[email protected]>
steve-calvert-glean
approved these changes
Apr 6, 2026
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.
Requests routed through the Glean Go SDK and the streaming chat endpoint were correctly sending
User-Agent: glean-cli/<version>, but several other HTTP call sites were not — OAuth discovery, dynamic client registration, domain lookup, GitHub release checks, and theglean apicommand all used barehttp.Client{}instances with no user-agent set.This adds an
internal/httputilpackage that centralizes both the CLI version string and User-Agent injection into a single place. All HTTP clients now go throughhttputil.NewHTTPClient(timeout)or compose onhttputil.NewTransport(base), which guarantees every outbound request identifies itself.As part of this, the
cliTransporttype ininternal/clientis eliminated — its only remaining job (injectingX-Glean-Auth-Typefor OAuth tokens) is now handled byhttputil.WithHeader, a general-purpose option onNewTransport.