Skip to content

Commit

Permalink
Merge pull request #128 from cybozu-go/fix-leak
Browse files Browse the repository at this point in the history
[client] always close resp.Body
  • Loading branch information
morimoto-cybozu authored Dec 25, 2018
2 parents 4a9afbc + bb57d76 commit 9305721
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ func (c *Client) do(req *http.Request) (*http.Response, error) {
case 200 <= resp.StatusCode && resp.StatusCode < 400:
case 400 <= resp.StatusCode && resp.StatusCode < 600:
body, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, err
}
resp.Body.Close()

var msg map[string]interface{}
err = json.Unmarshal(body, &msg)
Expand Down
2 changes: 1 addition & 1 deletion client/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type httpError struct {
}

func (e *httpError) Error() string {
return http.StatusText(e.code)
return http.StatusText(e.code) + ": " + e.reason
}

// Is4xx returns true if err contains 4xx status code
Expand Down

0 comments on commit 9305721

Please sign in to comment.