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

Function HttpClientFunc

pkg/cmd/factory/default.go:198–219  ·  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

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