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

Method RoundTrip

pkg/cmd/agent-task/capi/client.go:74–91  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

72}
73
74func (ct *capiTransport) RoundTrip(req *http.Request) (*http.Response, error) {
75 // Resolve the token per request so an expiring token is refreshed just before use. The base transport's own
76 // refresh is skipped once we set the Authorization header, so the CAPI transport must refresh here itself.
77 // Refresh is best effort: a failed refresh still yields the last stored token and the API decides its validity.
78 cred, _, _ := ct.authCfg.ActiveTokenWithRefresh(ct.host)
79 req.Header.Set("Authorization", "Bearer "+cred.Token)
80
81 // Since this RoundTrip is reused for both Copilot API and
82 // GitHub API requests, we conditionally add the integration
83 // ID only when performing requests to the Copilot API.
84 if req.URL.Host == ct.capiHost {
85 req.Header.Add("Copilot-Integration-Id", "copilot-4-cli")
86
87 // Ensure we are not using GitHub API versions while targeting CAPI.
88 req.Header.Set("X-GitHub-Api-Version", "2026-01-09")
89 }
90 return ct.rp.RoundTrip(req)
91}

Callers

nothing calls this directly

Calls 3

SetMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected