Skip to content

Commit

Permalink
fix a concurrency bug in the fasthttp client utility
Browse files Browse the repository at this point in the history
  • Loading branch information
nntaoli committed Sep 20, 2024
1 parent 0c34c16 commit 2fdbf71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion httpcli/fasthttp_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,9 @@ func (cli *FastHttpCli) DoRequest(method, rqUrl string, reqBody string, headers
return nil, errors.New(resp.String())
}

return resp.Body(), nil
// 拷贝响应的 body
responseBody := make([]byte, len(resp.Body()))
copy(responseBody, resp.Body())

return responseBody, nil
}

0 comments on commit 2fdbf71

Please sign in to comment.