From 2fdbf716ff544f51d64fd4b55dc729da0c87986a Mon Sep 17 00:00:00 2001 From: nntaoli <2767415655@qq.com> Date: Fri, 20 Sep 2024 10:36:23 +0800 Subject: [PATCH] fix a concurrency bug in the fasthttp client utility --- httpcli/fasthttp_cli.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/httpcli/fasthttp_cli.go b/httpcli/fasthttp_cli.go index fbaa3588..95137e42 100644 --- a/httpcli/fasthttp_cli.go +++ b/httpcli/fasthttp_cli.go @@ -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 }