test open files
This commit is contained in:
parent
2307e6eb10
commit
e165b6a0a0
22
response.go
22
response.go
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user