From b1c3df8a7da991ca86194ea8dada16a8d1249a75 Mon Sep 17 00:00:00 2001 From: cmstar Date: Wed, 5 Jul 2023 20:13:31 +0800 Subject: [PATCH] =?UTF-8?q?bug=20fix=EF=BC=9ASlimApiInvoker=20=E6=9C=AA?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E5=85=B3=E9=97=AD=20http.Response.Body=20?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- slimapi/slimapi_invoker.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/slimapi/slimapi_invoker.go b/slimapi/slimapi_invoker.go index 3b58ff8..1933950 100644 --- a/slimapi/slimapi_invoker.go +++ b/slimapi/slimapi_invoker.go @@ -77,6 +77,14 @@ func (x SlimApiInvoker[TParam, TData]) DoRaw(params TParam) (res webapi.ApiRespo return } + defer func() { + e := response.Body.Close() + if err == nil { + err = e + } + // Drop e if err is not nil. + }() + out, err := io.ReadAll(response.Body) if err != nil { err = wrapErr(err)