Skip to content

Commit

Permalink
Don't defer the read
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmcconnell authored Dec 2, 2024
1 parent dd84e2e commit 040aacb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions internal/server/health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ func (hc *HealthCheck) check() {
hc.reportResult(false, err)
return
}

defer func() {
_, _ = io.Copy(io.Discard, resp.Body)
resp.Body.Close()
}()
defer resp.Body.Close()

_, _ = io.Copy(io.Discard, resp.Body)

if resp.StatusCode < 200 || resp.StatusCode > 299 {
hc.reportResult(false, fmt.Errorf("%w (%d)", ErrorHealthCheckUnexpectedStatus, resp.StatusCode))
Expand Down

0 comments on commit 040aacb

Please sign in to comment.