From ee94e61aff33ce6d684cc69699550607d722bd54 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..70d0fe2 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() + bodycopy := make([]byte, len(body)) + copy(bodycopy, body) + return bodycopy, nil case fasthttp.StatusRequestEntityTooLarge: return nil, core.ErrRequestEntityTooLarge default: