Skip to content

Commit

Permalink
fixes a leak on every REST request (#779)
Browse files Browse the repository at this point in the history
per Do documentation: "If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close."

Co-authored-by: Joel Dodge <joeldodge@google.com>
  • Loading branch information
panoskoug and joeldodge79 authored Aug 6, 2021
1 parent 942f98e commit 4932baa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/rtl/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ func (s *AuthSession) Do(result interface{}, method, ver, path string, reqPars m
if err != nil {
return err
}
defer res.Body.Close()


if res.StatusCode < 200 || res.StatusCode > 226 {
return fmt.Errorf("response error: %s", res.Status)
Expand Down Expand Up @@ -209,4 +211,4 @@ func setQuery(u *url.URL, pars map[string]interface{}) {
}
}
u.RawQuery = q.Encode()
}
}

0 comments on commit 4932baa

Please sign in to comment.