MCPcopy Create free account
hub / github.com/imroc/req / Clone

Method Clone

client.go:1548–1579  ·  view source on GitHub ↗

Clone copy and returns the Client

()

Source from the content-addressed store, hash-verified

1546
1547// Clone copy and returns the Client
1548func (c *Client) Clone() *Client {
1549 cc := *c
1550
1551 // clone Transport
1552 cc.Transport = c.Transport.Clone()
1553 cc.initTransport()
1554
1555 // clone http.Client
1556 client := *c.httpClient
1557 client.Transport = cc.Transport
1558 cc.httpClient = &client
1559 cc.initCookieJar()
1560
1561 // clone client middleware
1562 if len(cc.roundTripWrappers) > 0 {
1563 cc.wrappedRoundTrip = roundTripImpl{&cc}
1564 for _, w := range cc.roundTripWrappers {
1565 cc.wrappedRoundTrip = w(cc.wrappedRoundTrip)
1566 }
1567 }
1568
1569 // clone other fields that may need to be cloned
1570 cc.PathParams = cloneMap(c.PathParams)
1571 cc.QueryParams = cloneUrlValues(c.QueryParams)
1572 cc.FormData = cloneUrlValues(c.FormData)
1573 cc.beforeRequest = cloneSlice(c.beforeRequest)
1574 cc.udBeforeRequest = cloneSlice(c.udBeforeRequest)
1575 cc.afterResponse = cloneSlice(c.afterResponse)
1576 cc.dumpOptions = c.dumpOptions.Clone()
1577 cc.retryOption = c.retryOption.Clone()
1578 return &cc
1579}
1580
1581func memoryCookieJarFactory() http.CookieJar {
1582 jar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})

Callers

nothing calls this directly

Calls 6

cloneMapFunction · 0.85
cloneUrlValuesFunction · 0.85
cloneSliceFunction · 0.85
initTransportMethod · 0.80
initCookieJarMethod · 0.80
CloneMethod · 0.65

Tested by

no test coverage detected