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

Function cloneRequest

config/http_config.go:1238–1250  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1236// cloneRequest returns a clone of the provided *http.Request.
1237// The clone is a shallow copy of the struct and its Header map.
1238func 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
1252type tlsConfigOptions struct {
1253 secretManager SecretManager

Callers 7

RoundTripMethod · 0.85
TestCloneRequestFunction · 0.85
RoundTripMethod · 0.85
RoundTripMethod · 0.85
RoundTripMethod · 0.85
RoundTripMethod · 0.85
RoundTripMethod · 0.85

Calls 1

CloneMethod · 0.45

Tested by 1

TestCloneRequestFunction · 0.68