Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2208,7 +2208,7 @@ func (c *Client) Clone(ctx context.Context) *Client {
}
// clone cookies
if l := len(c.cookies); l > 0 {
cc.cookies = make([]*http.Cookie, l)
cc.cookies = make([]*http.Cookie, 0, l)
for _, cookie := range c.cookies {
cc.cookies = append(cc.cookies, cloneCookie(cookie))
}
Expand Down
9 changes: 9 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,15 @@ func TestClientClone(t *testing.T) {

// assert interface/pointer type
assertEqual(t, parent.Client(), clone.Client())

// assert cookies
parentCookies := parent.Cookies()
cloneCookies := clone.Cookies()
assertEqual(t, len(parentCookies), len(cloneCookies))
for i := range parentCookies {
assertEqual(t, parentCookies[i].Name, cloneCookies[i].Name)
assertEqual(t, parentCookies[i].Value, cloneCookies[i].Value)
}
}

func TestResponseBodyLimit(t *testing.T) {
Expand Down