From e71797b40911b87c308214219201343fdb3c2c61 Mon Sep 17 00:00:00 2001 From: toshi-miura Date: Fri, 11 Oct 2019 16:02:04 +0900 Subject: [PATCH] =?UTF-8?q?ReadAll()=20&=20Close()=20=E3=80=80close=20toge?= =?UTF-8?q?ther.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/github.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/providers/github.go b/providers/github.go index dde166e9..f9821cb2 100644 --- a/providers/github.go +++ b/providers/github.go @@ -171,8 +171,6 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) { return false, err } - body, err := ioutil.ReadAll(resp.Body) - if last == 0 { // link header may not be obtained // 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) { } } - resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) if err != nil { + resp.Body.Close() return false, err } + resp.Body.Close() + if resp.StatusCode != 200 { return false, fmt.Errorf( "got %d from %q %s", resp.StatusCode, endpoint.String(), body)