From d710874903e00e13d0babbe681a9bf317440aab6 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 20 Jul 2026 22:22:40 +0200 Subject: [PATCH] chore: fix a couple of unclosed http connections (#10806) Signed-off-by: Jakob Borg --- lib/discover/global.go | 2 ++ lib/upnp/upnp.go | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/discover/global.go b/lib/discover/global.go index be70e1775..c944f0a2c 100644 --- a/lib/discover/global.go +++ b/lib/discover/global.go @@ -407,6 +407,7 @@ func (c *idCheckingHTTPClient) Get(ctx context.Context, url string) (*http.Respo return nil, err } if err := c.check(resp); err != nil { + resp.Body.Close() return nil, err } @@ -419,6 +420,7 @@ func (c *idCheckingHTTPClient) Post(ctx context.Context, url, ctype string, data return nil, err } if err := c.check(resp); err != nil { + resp.Body.Close() return nil, err } diff --git a/lib/upnp/upnp.go b/lib/upnp/upnp.go index 800218694..854bc7bf3 100644 --- a/lib/upnp/upnp.go +++ b/lib/upnp/upnp.go @@ -607,6 +607,7 @@ func soapRequestWithIP(ctx context.Context, url, service, function, message stri l.Debugln("SOAP do:", err) return resp, err } + defer r.Body.Close() resp, err = io.ReadAll(r.Body) if err != nil { @@ -616,8 +617,6 @@ func soapRequestWithIP(ctx context.Context, url, service, function, message stri l.Debugf("SOAP Response: %s\n\n%s\n\n", r.Status, resp) - r.Body.Close() - if r.StatusCode >= 400 { return resp, errors.New(function + ": " + r.Status) }