Skip to content

Commit

Permalink
Avoid duplicate Close() call on http.Response.Body (#365)
Browse files Browse the repository at this point in the history
* remove body close from decode function

* Update function comment
  • Loading branch information
Integralist authored Sep 8, 2022
1 parent fedbcfc commit 0b925cc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions fastly/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,7 @@ func checkResp(resp *http.Response, err error) (*http.Response, error) {
}

// decodeBodyMap is used to decode an HTTP response body into a mapstructure struct.
// It closes `body`.
func decodeBodyMap(body io.ReadCloser, out interface{}) error {
defer body.Close()

func decodeBodyMap(body io.Reader, out interface{}) error {
var parsed interface{}
dec := json.NewDecoder(body)
if err := dec.Decode(&parsed); err != nil {
Expand Down

0 comments on commit 0b925cc

Please sign in to comment.