MCPcopy Create free account
hub / github.com/cli/cli / HttpClientFunc

Function HttpClientFunc

pkg/cmd/factory/default.go:197–218  ·  view source on GitHub ↗
(cfgFunc func() (gh.Config, error), ios *iostreams.IOStreams, appVersion string, invokingAgent string, telemetryDisabler ghtelemetry.Disabler)

Source from the content-addressed store, hash-verified

195}
196
197func HttpClientFunc(cfgFunc func() (gh.Config, error), ios *iostreams.IOStreams, appVersion string, invokingAgent string, telemetryDisabler ghtelemetry.Disabler) func() (*http.Client, error) {
198 return func() (*http.Client, error) {
199 cfg, err := cfgFunc()
200 if err != nil {
201 return nil, err
202 }
203 opts := api.HTTPClientOptions{
204 RefreshingConfig: cfg.Authentication(),
205 Log: ios.ErrOut,
206 LogColorize: ios.ColorEnabled(),
207 AppVersion: appVersion,
208 InvokingAgent: invokingAgent,
209 TelemetryDisabler: telemetryDisabler,
210 }
211 client, err := api.NewHTTPClient(opts)
212 if err != nil {
213 return nil, err
214 }
215 client.Transport = api.ExtractHeader("X-GitHub-SSO", &ssoHeader)(client.Transport)
216 return client, nil
217 }
218}
219
220// tokenRefresherHttpClientFunc builds the HTTP client used to renew OAuth tokens. It mirrors plainHttpClientFunc but
221// defaults to headline-only logging so that, under GH_DEBUG=api, the refresh exchange does not produce a

Callers 6

TestVerifyIntegrationFunction · 0.92
TestSSOURLFunction · 0.85
NewFunction · 0.85

Calls 4

NewHTTPClientFunction · 0.92
ExtractHeaderFunction · 0.92
ColorEnabledMethod · 0.80
AuthenticationMethod · 0.65