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

Function ExtractHeader

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

306// ExtractHeader extracts a named header from any response received by this client and,
307// if non-blank, saves it to dest.
308func ExtractHeader(name string, dest *string) func(http.RoundTripper) http.RoundTripper {
309 return func(tr http.RoundTripper) http.RoundTripper {
310 return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
311 res, err := tr.RoundTrip(req)
312 if err == nil {
313 if value := res.Header.Get(name); value != "" {
314 *dest = value
315 }
316 }
317 return res, err
318 }}
319 }
320}
321
322type funcTripper struct {
323 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