git.iko.soy/typeable/oauth2-proxy
on master help sign in
ReadAll() & Close()  close together.
e71797btoshi-miura
providers/github.go+4−3
@@ -171,8 +171,6 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
171 return false, err
171 return false, err
172 }
172 }
173
173
174− body, err := ioutil.ReadAll(resp.Body)
175−
176 if last == 0 {
174 if last == 0 {
177 // link header may not be obtained
175 // link header may not be obtained
178 // When paging is not required and all data can be retrieved with a single call
176 // 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) {
196 }
194 }
197 }
195 }
198
196
199− resp.Body.Close()
197+ body, err := ioutil.ReadAll(resp.Body)
200 if err != nil {
198 if err != nil {
199+ resp.Body.Close()
201 return false, err
200 return false, err
202 }
201 }
202+ resp.Body.Close()
203+
203 if resp.StatusCode != 200 {
204 if resp.StatusCode != 200 {
204 return false, fmt.Errorf(
205 return false, fmt.Errorf(
205 "got %d from %q %s", resp.StatusCode, endpoint.String(), body)
206 "got %d from %q %s", resp.StatusCode, endpoint.String(), body)