From 31295ccfa2374e08276490830e787e23b249a9e6 Mon Sep 17 00:00:00 2001 From: andot Date: Fri, 26 Jan 2024 00:03:28 +0800 Subject: [PATCH] copy response body in fasthttp transport --- rpc/http/fasthttp/transport.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rpc/http/fasthttp/transport.go b/rpc/http/fasthttp/transport.go index acf5425..ddc1fe9 100644 --- a/rpc/http/fasthttp/transport.go +++ b/rpc/http/fasthttp/transport.go @@ -96,7 +96,10 @@ func (trans *Transport) Transport(ctx context.Context, request []byte) (response if !trans.DisableHTTPHeader { clientContext.Items().Set("httpResponseHeaders", getResponseHeader(&resp.Header)) } - return resp.SwapBody(nil), nil + body := resp.Body() + response := make([]byte, len(body)) + copy(response, body) + return response, nil case fasthttp.StatusRequestEntityTooLarge: return nil, core.ErrRequestEntityTooLarge default: