From b2401a7b7ebeeb3bafd0d1815904491152c530ec Mon Sep 17 00:00:00 2001 From: andot Date: Fri, 26 Jan 2024 00:07:09 +0800 Subject: [PATCH] copy request body in fasthttp handler --- rpc/http/handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rpc/http/handler.go b/rpc/http/handler.go index 8774264..bc3bd00 100644 --- a/rpc/http/handler.go +++ b/rpc/http/handler.go @@ -276,7 +276,10 @@ func (h *Handler) ServeFastHTTP(ctx *fasthttp.RequestCtx) { } } serviceContext := h.getFastHTTPServiceContext(ctx) - result, err := h.Service.Handle(core.WithContext(context.Background(), serviceContext), ctx.Request.Body()) + body := ctx.Request.Body() + request := make([]byte, len(body)) + copy(request, body) + result, err := h.Service.Handle(core.WithContext(context.Background(), serviceContext), request) if err != nil { h.onFastHTTPError(ctx, err) }