Clone copy and returns the Client
()
| 1546 | |
| 1547 | // Clone copy and returns the Client |
| 1548 | func (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 | |
| 1581 | func memoryCookieJarFactory() http.CookieJar { |
| 1582 | jar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List}) |
nothing calls this directly
no test coverage detected