git.iko.soy/typeable/oauth2-proxy
on master help sign in
ReadAll() & Close()  close together.
commite71797b40911b87c308214219201343fdb3c2c61 authortoshi-miura <toshihiko.miura@gmail.com> dateFri 11 Oct 2019, 16:02 (7 years ago) parent31d7b61
1 file changed+4−3
providers/github.go+4−3
providers/github.go+4−3
@@ -171,8 +171,6 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
171171 return false, err
172172 }
173173
174− body, err := ioutil.ReadAll(resp.Body)
175−
176174 if last == 0 {
177175 // link header may not be obtained
178176 // When paging is not required and all data can be retrieved with a single call
@@ -196,10 +194,13 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
196194 }
197195 }
198196
199− resp.Body.Close()
197+ body, err := ioutil.ReadAll(resp.Body)
200198 if err != nil {
199+ resp.Body.Close()
201200 return false, err
202201 }
202+ resp.Body.Close()
203+
203204 if resp.StatusCode != 200 {
204205 return false, fmt.Errorf(
205206 "got %d from %q %s", resp.StatusCode, endpoint.String(), body)