From 16859fc78e90c3fd4719dc3cdfe7b6ae2b943162 Mon Sep 17 00:00:00 2001 From: eson <474420502@qq.com> Date: Tue, 18 Dec 2018 00:21:27 +0800 Subject: [PATCH] add close Reader --- response.go | 2 ++ session_test.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/response.go b/response.go index 3176aeb..9e2da78 100644 --- a/response.go +++ b/response.go @@ -38,12 +38,14 @@ func FromHTTPResponse(resp *http.Response) (*Response, error) { srcReader := bytes.NewReader(srcbuf) if r, err := gzip.NewReader(srcReader); err == nil { + defer r.Close() buf, err := ioutil.ReadAll(r) if err != nil { panic(err) } content = string(buf) } else if r, err := zlib.NewReader(srcReader); err == nil { + defer r.Close() buf, err := ioutil.ReadAll(r) if err != nil { panic(err) diff --git a/session_test.go b/session_test.go index fc68714..e249136 100644 --- a/session_test.go +++ b/session_test.go @@ -319,7 +319,7 @@ func TestSession_SetConfig(t *testing.T) { func TestSession_SetConfigInsecure(t *testing.T) { ses := NewSession() - ses.SetConfig(CInsecure, false) + ses.SetConfig(CInsecure, true) for _, badSSL := range []string{ "https://self-signed.badssl.com/",