Skip to content

Commit

Permalink
fix: Close response after StatusCode !=200
Browse files Browse the repository at this point in the history
  • Loading branch information
jie authored and jie committed Sep 2, 2020
1 parent 7cf137e commit e279c53
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions util/httpUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func GetHTTPResponse(resp *http.Response, url string, err error, result interfac
if err != nil {
log.Printf("请求接口%s失败! ERROR: %s\n", url, err)
} else if resp.StatusCode != 200 {
defer resp.Body.Close()
log.Printf("请求接口%s失败! StatusCode: %d", url, resp.StatusCode)
return errors.New("Response status code not equals 200")
} else {
Expand Down

0 comments on commit e279c53

Please sign in to comment.