From 85034cfb35f6fe255c090929eb8d7073de9811c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Fri, 15 Nov 2024 16:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=A1=E5=AF=86=EF=BC=8C=E7=9B=B4=E5=85=85,R?= =?UTF-8?q?equest=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dctw/v1/core/core.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dctw/v1/core/core.go b/dctw/v1/core/core.go index f832022..2c4bf08 100644 --- a/dctw/v1/core/core.go +++ b/dctw/v1/core/core.go @@ -159,9 +159,7 @@ func (c *DctWServer) Request(_ context.Context, request DctWRequest, path string } signStr := c.Sign(string(body), path, timestamp) url := fmt.Sprintf("%s%s", c.Config.BaseUri, path) - httpClient := &http.Client{ - Timeout: 15 * time.Second, - } + req, err := http.NewRequest("POST", url, bytes.NewBuffer(body)) if err != nil { return nil, err @@ -170,13 +168,13 @@ func (c *DctWServer) Request(_ context.Context, request DctWRequest, path string req.Header = c.Headers(signStr, timestamp) if c.DeBug { - fmt.Printf("url:%s\n", url) - fmt.Printf("body:%s\n", string(body)) - fmt.Printf("signStr:%s\n", signStr) - fmt.Printf("Headers:%+v\n", req.Header) + fmt.Printf("request.url:%s\n", url) + fmt.Printf("request.body:%s\n", string(body)) + fmt.Printf("request.signStr:%s\n", signStr) + fmt.Printf("request.headers:%+v\n", req.Header) } - resp, err := httpClient.Do(req) + resp, err := c.HttpClient.Do(req) if err != nil { return nil, err } @@ -187,7 +185,8 @@ func (c *DctWServer) Request(_ context.Context, request DctWRequest, path string } if c.DeBug { fmt.Printf("resp.Status:%s\n", resp.Status) - fmt.Printf("bodyStr:%s\n", string(bodyBytes)) + fmt.Printf("resp.body:%s\n", string(bodyBytes)) + fmt.Printf("resp.headers:%+v\n", resp.Header) } return bodyBytes, nil