From 0f8848e92a74bf9024d1ae6517e18261e0be63bb Mon Sep 17 00:00:00 2001 From: Dhi Aurrahman Date: Thu, 8 Feb 2018 11:37:03 +0700 Subject: [PATCH 1/3] Remove unnecessary drain resp.Body The behavior on connection reuse without manually draining resp.Body is introduced in golang/go@18072ad. Fixes #843 --- github/github.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/github/github.go b/github/github.go index f3eadce9e97..f5bffe6eb52 100644 --- a/github/github.go +++ b/github/github.go @@ -478,12 +478,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Res return nil, err } - defer func() { - // Drain up to 512 bytes and close the body to let the Transport reuse the connection - io.CopyN(ioutil.Discard, resp.Body, 512) - resp.Body.Close() - }() - + resp.Body.Close() response := newResponse(resp) c.rateMu.Lock() From a4638269746dcca9e768f888f12529a9dbc057cd Mon Sep 17 00:00:00 2001 From: Dhi Aurrahman Date: Tue, 27 Feb 2018 06:08:52 +0700 Subject: [PATCH 2/3] Add defer statement --- github/github.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/github.go b/github/github.go index f5bffe6eb52..0a4d3f1fcf1 100644 --- a/github/github.go +++ b/github/github.go @@ -478,7 +478,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Res return nil, err } - resp.Body.Close() + defer resp.Body.Close() response := newResponse(resp) c.rateMu.Lock() From d285239f10debdeece9710b1b15449b03bf9e41c Mon Sep 17 00:00:00 2001 From: Dhi Aurrahman Date: Mon, 5 Mar 2018 18:04:28 +0700 Subject: [PATCH 3/3] Review feedback for removing blank line --- github/github.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/github.go b/github/github.go index 0a4d3f1fcf1..258145a954b 100644 --- a/github/github.go +++ b/github/github.go @@ -477,8 +477,8 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Res return nil, err } - defer resp.Body.Close() + response := newResponse(resp) c.rateMu.Lock()