fix issue: request body was closed while retrying in callRequest method (#3199)

This commit is contained in:
zhangyuyu
2023-12-14 14:18:31 +08:00
committed by GitHub
parent ee2cf92479
commit 33584506ab

View File

@ -338,8 +338,8 @@ func (c *Client) callRequest(req *http.Request) (resp *Response, err error) {
// raw HTTP request-response procedure.
reqBodyContent, _ := io.ReadAll(req.Body)
resp.requestBody = reqBodyContent
req.Body = utils.NewReadCloser(reqBodyContent, false)
for {
req.Body = utils.NewReadCloser(reqBodyContent, false)
if resp.Response, err = c.Do(req); err != nil {
err = gerror.Wrapf(err, `request failed`)
// The response might not be nil when err != nil.