From aba1f541f54978a549ffa995696407a50328ad86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Thu, 22 Aug 2024 10:53:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6-=E4=BA=91=E9=97=AA=E4=BB=98?= =?UTF-8?q?=E7=BA=A2=E5=8C=85,=E6=9F=A5=E8=AF=A2=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/union_pay_redpack/internal/union_pay_redpack.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/union_pay_redpack/internal/union_pay_redpack.go b/plugins/union_pay_redpack/internal/union_pay_redpack.go index 6f3908a..79561e2 100644 --- a/plugins/union_pay_redpack/internal/union_pay_redpack.go +++ b/plugins/union_pay_redpack/internal/union_pay_redpack.go @@ -5,7 +5,9 @@ import ( "fmt" "gitea.cdlsxd.cn/BaseSystem/plugin/proto" "github.com/carlmjohnson/requests" + "net/http" "plugins/union_pay_redpack/internal/po" + "time" ) // 插件通信信息,若不对应则会报错panic @@ -64,7 +66,10 @@ func (p *UnionPayCpnService) Query(ctx context.Context, request *proto.QueryRequ } var response po.QueryResp url := fmt.Sprintf("%s%s", c.BaseUri, queryMethod) - err = requests.URL(url).Headers(headers(c, uv, queryBizMethod)).BodyJSON(uv).ToJSON(&response).Fetch(ctx) + + h := new(http.Client) + h.Timeout = 100 * time.Millisecond + err = requests.URL(url).Client(h).Headers(headers(c, uv, queryBizMethod)).BodyJSON(uv).ToJSON(&response).Fetch(ctx) if err != nil { return nil, fmt.Errorf("请求异常,msg:" + err.Error()) }