From c22a85e2b56696b50dd08efd4ecf5ac668db365c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 14 Jul 2022 19:10:32 +0200 Subject: [PATCH] Remove accidental caching from `repo list` and other commands Any gh command that has invoked NewCachedHTTPClient has also inadvertently enabled caching for the original `http.Client` due to the nature that NewCachedHTTPClient mutates the original argument passed. --- api/http_client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/http_client.go b/api/http_client.go index 9ea6ca1fb..634559508 100644 --- a/api/http_client.go +++ b/api/http_client.go @@ -60,8 +60,9 @@ func NewHTTPClient(opts HTTPClientOptions) (*http.Client, error) { } func NewCachedHTTPClient(httpClient *http.Client, ttl time.Duration) *http.Client { - httpClient.Transport = AddCacheTTLHeader(httpClient.Transport, ttl) - return httpClient + newClient := *httpClient + newClient.Transport = AddCacheTTLHeader(httpClient.Transport, ttl) + return &newClient } // AddCacheTTLHeader adds an header to the request telling the cache that the request