MCPcopy Create free account
hub / github.com/prometheus/common / RoundTrip

Method RoundTrip

config/http_config.go:629–642  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

627}
628
629func (rt *authorizationCredentialsFileRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
630 if len(req.Header.Get("Authorization")) == 0 {
631 b, err := os.ReadFile(rt.authCredentialsFile)
632 if err != nil {
633 return nil, fmt.Errorf("unable to read authorization credentials file %s: %w", rt.authCredentialsFile, err)
634 }
635 authCredentials := strings.TrimSpace(string(b))
636
637 req = cloneRequest(req)
638 req.Header.Set("Authorization", fmt.Sprintf("%s %s", rt.authType, authCredentials))
639 }
640
641 return rt.rt.RoundTrip(req)
642}
643
644func (rt *authorizationCredentialsFileRoundTripper) CloseIdleConnections() {
645 if ci, ok := rt.rt.(closeIdler); ok {

Callers

nothing calls this directly

Calls 4

cloneRequestFunction · 0.85
GetMethod · 0.80
SetMethod · 0.45
RoundTripMethod · 0.45

Tested by

no test coverage detected