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

Function NewCachedHTTPClientWithStatuses

api/http_client.go:195–199  ·  view source on GitHub ↗

NewCachedHTTPClientWithStatuses is like NewCachedHTTPClient, but it also caches responses with the given status codes, such as 403, which are not cached by default.

(httpClient *http.Client, ttl time.Duration, statuses ...int)

Source from the content-addressed store, hash-verified

193// NewCachedHTTPClientWithStatuses is like NewCachedHTTPClient, but it also caches responses with the given status
194// codes, such as 403, which are not cached by default.
195func NewCachedHTTPClientWithStatuses(httpClient *http.Client, ttl time.Duration, statuses ...int) *http.Client {
196 newClient := NewCachedHTTPClient(httpClient, ttl)
197 newClient.Transport = addCacheStatusesHeader(newClient.Transport, statuses...)
198 return newClient
199}
200
201func addCacheStatusesHeader(rt http.RoundTripper, statuses ...int) http.RoundTripper {
202 if len(statuses) == 0 {

Callers 2

clientMethod · 0.92

Calls 2

NewCachedHTTPClientFunction · 0.85
addCacheStatusesHeaderFunction · 0.85

Tested by 1