From 05b6be76a8dc13dd87f0b7980509af04c5bf666b Mon Sep 17 00:00:00 2001 From: Yun Date: Sat, 23 Mar 2024 13:50:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- curlx.go | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/curlx.go b/curlx.go index ecb36ae..ec55d7d 100644 --- a/curlx.go +++ b/curlx.go @@ -166,29 +166,29 @@ func (c *Curlx) SendWithResponee(ctx context.Context, ps ...Param) Response { return r } var body []byte - switch resp.Header.Get("Content-Encoding") { - case "gzip": - reader, err := gzip.NewReader(resp.Body) - if err != nil { - r.err = err - return r - } - for { - buf := make([]byte, 1024) - n, err := reader.Read(buf) - if err != nil && err != io.EOF { - panic(err) - } - if n == 0 { - break - } - // 读取n个字节 - body = append(body, buf[:n]...) - // body = append(body, buf...) - } - default: - body, _ = io.ReadAll(resp.Body) - } + // switch resp.Header.Get("Content-Encoding") { + // case "gzip": + // reader, err := gzip.NewReader(resp.Body) + // if err != nil { + // r.err = err + // return r + // } + // for { + // buf := make([]byte, 1024) + // n, err := reader.Read(buf) + // if err != nil && err != io.EOF { + // panic(err) + // } + // if n == 0 { + // break + // } + // // 读取n个字节 + // body = append(body, buf[:n]...) + // // body = append(body, buf...) + // } + // default: + body, _ = io.ReadAll(resp.Body) + // } r.body = body c.opts.Logger.Infof(ctx, "curlx.Send body:%s", string(body)) return r