test open files

This commit is contained in:
eson 2018-12-18 01:36:18 +08:00
parent 2307e6eb10
commit e165b6a0a0

View File

@ -33,23 +33,29 @@ func FromHTTPResponse(resp *http.Response) (*Response, error) {
// resp.Body = ioutil.NopCloser(cbuf)
content := string(srcbuf)
content := ""
srcReader := bytes.NewReader(srcbuf)
if r, err := gzip.NewReader(srcReader); err == nil {
defer r.Close()
r, err := gzip.NewReader(srcReader)
defer r.Close()
if err == nil {
buf, err := ioutil.ReadAll(r)
if err != nil {
panic(err)
}
content = string(buf)
} else if r, err := zlib.NewReader(srcReader); err == nil {
} else {
r, err := zlib.NewReader(srcReader)
defer r.Close()
buf, err := ioutil.ReadAll(r)
if err != nil {
panic(err)
if err == nil {
buf, err := ioutil.ReadAll(r)
if err != nil {
panic(err)
}
content = string(buf)
} else {
content = string(srcbuf)
}
content = string(buf)
}
return &Response{DContent: content, GResponse: resp}, nil