RoundTrip implements http.RoundTripper.
(req *http.Request)
| 112 | |
| 113 | // RoundTrip implements http.RoundTripper. |
| 114 | func (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. |
| 135 | func (rt *headersRoundTripper) CloseIdleConnections() { |
nothing calls this directly
no test coverage detected