bugfix: preserve original transport for linear http client (#6357)

This commit is contained in:
Ice3man 2025-07-30 21:38:07 +05:30 committed by GitHub
parent 05f69a6b24
commit 06707ea76f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,15 +54,17 @@ type Options struct {
// New creates a new issue tracker integration client based on options. // New creates a new issue tracker integration client based on options.
func New(options *Options) (*Integration, error) { func New(options *Options) (*Integration, error) {
var transport http.RoundTripper = http.DefaultTransport
if options.HttpClient != nil && options.HttpClient.HTTPClient.Transport != nil {
transport = options.HttpClient.HTTPClient.Transport
}
httpClient := &http.Client{ httpClient := &http.Client{
Transport: &addHeaderTransport{ Transport: &addHeaderTransport{
T: http.DefaultTransport, T: transport,
Key: options.APIKey, Key: options.APIKey,
}, },
} }
if options.HttpClient != nil {
httpClient.Transport = options.HttpClient.HTTPClient.Transport
}
integration := &Integration{ integration := &Integration{
url: "https://api.linear.app/graphql", url: "https://api.linear.app/graphql",
@ -385,8 +387,8 @@ func (i *Integration) doGraphqlRequest(ctx context.Context, query string, v any,
return err return err
} }
defer func() { defer func() {
_ = resp.Body.Close() _ = resp.Body.Close()
}() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
return fmt.Errorf("non-200 OK status code: %v body: %q", resp.Status, body) return fmt.Errorf("non-200 OK status code: %v body: %q", resp.Status, body)