MCPcopy Index your code
hub / github.com/cli/cli / ExtractHeader

Function ExtractHeader

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

173// ExtractHeader extracts a named header from any response received by this client and,
174// if non-blank, saves it to dest.
175func ExtractHeader(name string, dest *string) func(http.RoundTripper) http.RoundTripper {
176 return func(tr http.RoundTripper) http.RoundTripper {
177 return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
178 res, err := tr.RoundTrip(req)
179 if err == nil {
180 if value := res.Header.Get(name); value != "" {
181 *dest = value
182 }
183 }
184 return res, err
185 }}
186 }
187}
188
189type funcTripper struct {
190 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