Skip to content

Commit b4fa836

Browse files
committed
Close response body to avoid leaks in http retry
Claude suggested this after reviewing the previous commit. Ref: https://issues.redhat.com/browse/EC-1404 Co-authored-by: Claude Sonnet 4
1 parent 5302c52 commit b4fa836

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/http/retry.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ func (r *retryTransport) RoundTrip(req *http.Request) (*http.Response, error) {
116116

117117
// If we get a 429, 408, or 503, retry with exponential backoff
118118
if resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode == http.StatusRequestTimeout || resp.StatusCode == http.StatusServiceUnavailable {
119+
// Close the response body to avoid resource leaks during retries
120+
if resp.Body != nil {
121+
resp.Body.Close()
122+
}
119123
lastResp = resp
120124
lastErr = nil
121125

0 commit comments

Comments
 (0)