丑陋的解压

This commit is contained in:
eson 2018-12-18 01:42:38 +08:00
parent e165b6a0a0
commit 75fc71ccb4

View File

@ -37,23 +37,30 @@ func FromHTTPResponse(resp *http.Response) (*Response, error) {
srcReader := bytes.NewReader(srcbuf)
r, err := gzip.NewReader(srcReader)
defer r.Close()
if err == nil {
defer r.Close()
buf, err := ioutil.ReadAll(r)
if err != nil {
panic(err)
}
content = string(buf)
} else {
if r != nil {
r.Close()
}
r, err := zlib.NewReader(srcReader)
defer r.Close()
if err == nil {
defer r.Close()
buf, err := ioutil.ReadAll(r)
if err != nil {
panic(err)
}
content = string(buf)
} else {
if r != nil {
r.Close()
}
content = string(srcbuf)
}
}