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

Method RoundTrip

config/headers.go:114–132  ·  view source on GitHub ↗

RoundTrip implements http.RoundTripper.

(req *http.Request)

Source from the content-addressed store, hash-verified

112
113// RoundTrip implements http.RoundTripper.
114func (rt *headersRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
115 req = cloneRequest(req)
116 for n, h := range rt.config.Headers {
117 for _, v := range h.Values {
118 req.Header.Add(n, v)
119 }
120 for _, v := range h.Secrets {
121 req.Header.Add(n, string(v))
122 }
123 for _, v := range h.Files {
124 b, err := os.ReadFile(v)
125 if err != nil {
126 return nil, fmt.Errorf("unable to read headers file %s: %w", v, err)
127 }
128 req.Header.Add(n, strings.TrimSpace(string(b)))
129 }
130 }
131 return rt.next.RoundTrip(req)
132}
133
134// CloseIdleConnections implements closeIdler.
135func (rt *headersRoundTripper) CloseIdleConnections() {

Callers

nothing calls this directly

Calls 2

cloneRequestFunction · 0.85
AddMethod · 0.80

Tested by

no test coverage detected