From 36bf1b9b5b1e6ee0f9e992b835b6e09dc191138e Mon Sep 17 00:00:00 2001 From: ZhoukunCheng Date: Fri, 27 Feb 2026 15:29:42 +0800 Subject: [PATCH] fix: deep-clone httpClient in Clone() to prevent shared Timeout mutation resty.Clone() did `cc := *c` which shallow-copies the httpClient pointer, so all clones shared the same *http.Client. Calling SetTimeout() on any clone mutated the shared object and affected every other client. Fix: value-copy *http.Client in Clone() so each clone gets its own instance. Co-Authored-By: Claude Sonnet 4.6 --- client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client.go b/client.go index a1fe26c..a0be8a0 100644 --- a/client.go +++ b/client.go @@ -1222,6 +1222,12 @@ func (c *Client) Clone() *Client { cc.invalidHooks = slices.Clone(c.invalidHooks) cc.panicHooks = slices.Clone(c.panicHooks) + // httpClient is a pointer; clone it so that mutations (e.g. SetTimeout) + // on the clone do not affect the original or any other client sharing + // the same underlying *http.Client. + hc := *c.httpClient + cc.httpClient = &hc + return &cc }