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

Function ExtractHeader

api/http_client.go:260–272  ·  view source on GitHub ↗

ExtractHeader extracts a named header from any response received by this client and, if non-blank, saves it to dest.

(name string, dest *string)

Source from the content-addressed store, hash-verified

258// ExtractHeader extracts a named header from any response received by this client and,
259// if non-blank, saves it to dest.
260func ExtractHeader(name string, dest *string) func(http.RoundTripper) http.RoundTripper {
261 return func(tr http.RoundTripper) http.RoundTripper {
262 return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
263 res, err := tr.RoundTrip(req)
264 if err == nil {
265 if value := res.Header.Get(name); value != "" {
266 *dest = value
267 }
268 }
269 return res, err
270 }}
271 }
272}
273
274type funcTripper struct {
275 roundTrip func(*http.Request) (*http.Response, error)

Callers 1

HttpClientFuncFunction · 0.92

Calls 2

GetMethod · 0.65
RoundTripMethod · 0.45

Tested by

no test coverage detected