From ef78631a7c2a1fc3de874d85ea08b7e8d9d3ca02 Mon Sep 17 00:00:00 2001 From: chrislu Date: Wed, 31 Aug 2022 00:10:17 -0700 Subject: [PATCH] just a bit safer --- weed/util/http_util.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/weed/util/http_util.go b/weed/util/http_util.go index 748bb6e87..bb1a32ede 100644 --- a/weed/util/http_util.go +++ b/weed/util/http_util.go @@ -408,6 +408,9 @@ func ReadUrlAsReaderCloser(fileUrl string, jwt string, rangeHeader string) (*htt } func CloseResponse(resp *http.Response) { + if resp == nil || resp.Body == nil { + return + } reader := &CountingReader{reader: resp.Body} io.Copy(io.Discard, reader) resp.Body.Close()