(req *http.Request)
| 72 | } |
| 73 | |
| 74 | func (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 | } |
nothing calls this directly
no test coverage detected