From b4c9806e7d966e1f58a21197b3ccf177169b8628 Mon Sep 17 00:00:00 2001 From: Zeng Ke Date: Fri, 27 Oct 2023 19:48:12 +0800 Subject: [PATCH] piprequest, read request body to byte buffer --- nodemux/core/endpoint.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nodemux/core/endpoint.go b/nodemux/core/endpoint.go index 53b1324..ecf4e12 100644 --- a/nodemux/core/endpoint.go +++ b/nodemux/core/endpoint.go @@ -159,7 +159,11 @@ func (self *Endpoint) RespondRequest(rootCtx context.Context, path string, r *ht // prepare request // TODO: join the server url and method url := self.FullUrl(path) - req, err := http.NewRequestWithContext(ctx, r.Method, url, r.Body) + body, err := io.ReadAll(r.Body) + if err != nil { + return nil, err + } + req, err := http.NewRequestWithContext(ctx, r.Method, url, io.NopCloser(bytes.NewBuffer(body))) if err != nil { return nil, errors.Wrap(err, "http.NewRequestWithContext") }