httpHead: return error before referencying resp.Body

This commit is contained in:
Jehiah Czebotar 2016-02-06 00:41:15 -05:00
parent be4e74d1aa
commit 9dc7fa9d52

View file

@ -33,9 +33,10 @@ func httpHead(url string) (resp *http.Response, err error) {
req.Header.Set("User-Agent", userAgent())
resp, err = http.DefaultClient.Do(req)
if resp.Body != nil {
resp.Body.Close()
if err != nil {
return resp, err
}
resp.Body.Close()
return resp, err
}