Skip to content

Commit

Permalink
http_get: close response body early to avoid any leak
Browse files Browse the repository at this point in the history
  • Loading branch information
azr committed Dec 14, 2018
1 parent 9fd936f commit 937d58d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion get_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func (g *HttpGetter) GetFile(dst string, src *url.URL) error {
}
headResp, err := g.Client.Do(req)
if err == nil && headResp != nil {
headResp.Body.Close()
if headResp.StatusCode == 200 {
// If the HEAD request succeeded, then attempt to set the range
// query if we can.
Expand All @@ -179,7 +180,6 @@ func (g *HttpGetter) GetFile(dst string, src *url.URL) error {
}
}
}
headResp.Body.Close()
}
req.Method = "GET"

Expand Down

0 comments on commit 937d58d

Please sign in to comment.