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

Function ExtractHeader

api/http_client.go:281–293  ·  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

279// ExtractHeader extracts a named header from any response received by this client and,
280// if non-blank, saves it to dest.
281func ExtractHeader(name string, dest *string) func(http.RoundTripper) http.RoundTripper {
282 return func(tr http.RoundTripper) http.RoundTripper {
283 return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
284 res, err := tr.RoundTrip(req)
285 if err == nil {
286 if value := res.Header.Get(name); value != "" {
287 *dest = value
288 }
289 }
290 return res, err
291 }}
292 }
293}
294
295type funcTripper struct {
296 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