cloneRequest returns a clone of the provided *http.Request. The clone is a shallow copy of the struct and its Header map.
(r *http.Request)
| 1236 | // cloneRequest returns a clone of the provided *http.Request. |
| 1237 | // The clone is a shallow copy of the struct and its Header map. |
| 1238 | func cloneRequest(r *http.Request) *http.Request { |
| 1239 | // Shallow copy of the struct. |
| 1240 | r2 := new(http.Request) |
| 1241 | *r2 = *r |
| 1242 | // Deep copy of the Header. The shallow copy above leaves r2.Header |
| 1243 | // aliasing r.Header, so without this every round tripper that adds a |
| 1244 | // header would mutate the caller's request. |
| 1245 | r2.Header = r.Header.Clone() |
| 1246 | if r2.Header == nil { |
| 1247 | r2.Header = make(http.Header) |
| 1248 | } |
| 1249 | return r2 |
| 1250 | } |
| 1251 | |
| 1252 | type tlsConfigOptions struct { |
| 1253 | secretManager SecretManager |