File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1125,6 +1125,25 @@ func (c *Client) GetClient() *http.Client {
1125
1125
return c .httpClient
1126
1126
}
1127
1127
1128
+ // Clone returns a clone of the original client.
1129
+ //
1130
+ // Be carefull when using this function:
1131
+ // - Interface values are not deeply cloned. Thus, both the original and the clone will use the
1132
+ // same value.
1133
+ // - This function is not safe for concurrent use. You should only use this when you are sure that
1134
+ // the client is not being used by any other goroutine.
1135
+ //
1136
+ // Since v2.12.0
1137
+ func (c * Client ) Clone () * Client {
1138
+ // dereference the pointer and copy the value
1139
+ cc := * c
1140
+
1141
+ // lock values should not be copied - thus new values are used.
1142
+ cc .afterResponseLock = & sync.RWMutex {}
1143
+ cc .udBeforeRequestLock = & sync.RWMutex {}
1144
+ return & cc
1145
+ }
1146
+
1128
1147
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
1129
1148
// Client Unexported methods
1130
1149
//_______________________________________________________________________
You can’t perform that action at this time.
0 commit comments