Skip to content

Commit

Permalink
check resp.Body if nil before attempting to close
Browse files Browse the repository at this point in the history
  • Loading branch information
sonroyaalmerol committed Aug 29, 2024
1 parent 7efb1f1 commit 99113bb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions proxy/stream_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ func (instance *StreamInstance) LoadBalancer(previous *[]int, method string) (*h
utils.SafeLogf("[DEBUG] Error fetching stream from %s: %s\n", url, err.Error())
}

_, _ = io.Copy(io.Discard, resp.Body)
resp.Body.Close()
if resp.Body != nil {
_, _ = io.Copy(io.Discard, resp.Body)
resp.Body.Close()
}
}

if allSkipped {
Expand Down

0 comments on commit 99113bb

Please sign in to comment.