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

Function ExtractHeader

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

192// ExtractHeader extracts a named header from any response received by this client and,
193// if non-blank, saves it to dest.
194func ExtractHeader(name string, dest *string) func(http.RoundTripper) http.RoundTripper {
195 return func(tr http.RoundTripper) http.RoundTripper {
196 return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
197 res, err := tr.RoundTrip(req)
198 if err == nil {
199 if value := res.Header.Get(name); value != "" {
200 *dest = value
201 }
202 }
203 return res, err
204 }}
205 }
206}
207
208type funcTripper struct {
209 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