一些优化

This commit is contained in:
Yun
2024-03-23 13:56:59 +08:00
parent 05b6be76a8
commit ba0e151e3e
+22 -1
View File
@@ -187,8 +187,29 @@ func (c *Curlx) SendWithResponee(ctx context.Context, ps ...Param) Response {
// // body = append(body, buf...)
// }
// default:
body, _ = io.ReadAll(resp.Body)
// body, _ = io.ReadAll(resp.Body)
// }
if resp.Header.Get("Content-Encoding") == "gzip" {
reader, err := gzip.NewReader(resp.Body)
if err != nil {
r.err = err
return r
}
body, err = io.ReadAll(reader)
if err != nil {
r.err = err
return r
}
defer reader.Close()
} else {
body, err = io.ReadAll(resp.Body)
if err != nil {
r.err = err
return r
}
}
r.body = body
c.opts.Logger.Infof(ctx, "curlx.Send body:%s", string(body))
return r