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

Function addCacheStatusesHeader

api/http_client.go:201–217  ·  view source on GitHub ↗
(rt http.RoundTripper, statuses ...int)

Source from the content-addressed store, hash-verified

199}
200
201func addCacheStatusesHeader(rt http.RoundTripper, statuses ...int) http.RoundTripper {
202 if len(statuses) == 0 {
203 return rt
204 }
205 values := make([]string, len(statuses))
206 for i, status := range statuses {
207 values[i] = strconv.Itoa(status)
208 }
209 value := strings.Join(values, ",")
210 return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
211 // If the header is already set in the request, don't overwrite it.
212 if req.Header.Get(cacheStatuses) == "" {
213 req.Header.Set(cacheStatuses, value)
214 }
215 return rt.RoundTrip(req)
216 }}
217}
218
219// AddCacheTTLHeader adds a header to the request telling the cache that the request
220// should be cached for a specified amount of time.

Callers 1

Calls 4

JoinMethod · 0.80
GetMethod · 0.65
SetMethod · 0.65
RoundTripMethod · 0.45

Tested by

no test coverage detected