Skip to content

cmd: close response body on download error (#7833)#7837

Open
vvdvortsova wants to merge 1 commit into
caddyserver:masterfrom
vvdvortsova:fix-7833-2-add-close
Open

cmd: close response body on download error (#7833)#7837
vvdvortsova wants to merge 1 commit into
caddyserver:masterfrom
vvdvortsova:fix-7833-2-add-close

Conversation

@vvdvortsova

Copy link
Copy Markdown

I'm not a native English speaker, so I used AI to help translate this PR description. The code and analysis are my own.

What
Fix resource leak in downloadBuild.
Fix for issue #7833.

downloadBuild in cmd/packagesfuncs.go returned early on HTTP error responses (resp.StatusCode >= 400) without closing resp.Body, leaking the underlying connection instead of returning it to the pool. Added defer resp.Body.Close() right after the status check, so the body is closed on both error-decoding paths. The success path (return resp, nil) is untouched the caller still owns and closes that body.

Testing
go build ./cmd/...
go vet ./cmd/...

@CLAassistant

CLAassistant commented Jun 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants