add close Reader

This commit is contained in:
eson 2018-12-18 00:21:27 +08:00
parent 72491204d6
commit 16859fc78e
2 changed files with 3 additions and 1 deletions

View File

@ -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)

View File

@ -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/",