From ccf5c45b32234449257252f5cf8c9be0b89020d4 Mon Sep 17 00:00:00 2001 From: wxg Date: Fri, 17 Jan 2025 14:56:12 +0800 Subject: [PATCH] fix(common): update req.Body in netretry.go --- tencentcloud/common/netretry.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tencentcloud/common/netretry.go b/tencentcloud/common/netretry.go index f385944980..3fe178fb62 100644 --- a/tencentcloud/common/netretry.go +++ b/tencentcloud/common/netretry.go @@ -24,6 +24,15 @@ func (c *Client) sendWithNetworkFailureRetry(req *http.Request, retryable bool) durationFunc := safeDurationFunc(c.profile.NetworkFailureRetryDuration) for idx := 0; idx <= maxRetries; idx++ { + if idx > 0 && req.ContentLength > 0 { + if body, err := req.GetBody(); err != nil { + msg := fmt.Sprintf("Fail to get body because %s", err) + err = errors.NewTencentCloudSDKError("ClientError.NetworkError", msg, "") + return resp, err + } else { + req.Body = body + } + } resp, err = c.sendHttp(req) // retry when error occurred and retryable and not the last retry