From 88a81fbcafc27e19b731c31a9ef137603258b0a0 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:00:55 +0200 Subject: [PATCH] [chore] Close copied request body in SignDelivery (#3254) --- internal/transport/deliver.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/transport/deliver.go b/internal/transport/deliver.go index 36ad6f015..e8017b2a6 100644 --- a/internal/transport/deliver.go +++ b/internal/transport/deliver.go @@ -175,14 +175,18 @@ func (t *transport) SignDelivery(dlv *delivery.Delivery) error { return gtserror.New("delivery request body not rewindable") } - // Get a new copy of the request body. - body, err := dlv.Request.GetBody() + // Fetch a fresh copy of request body. + rBody, err := dlv.Request.GetBody() if err != nil { return gtserror.Newf("error getting request body: %w", err) } // Read body data into memory. - data, err := io.ReadAll(body) + data, err := io.ReadAll(rBody) + + // Done with body. + _ = rBody.Close() + if err != nil { return gtserror.Newf("error reading request body: %w", err) }