From bab271d562e20614fd61bfd4e38ae9af0eb98942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 9 Jun 2024 19:56:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E5=A2=9E=E5=8A=A0ht?= =?UTF-8?q?tp=E7=8A=B6=E6=80=81=E7=A0=81=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client.go b/client.go index 3e3728e..2485002 100644 --- a/client.go +++ b/client.go @@ -15,6 +15,7 @@ import ( "git.zhangdeman.cn/zhangdeman/serialize" "github.com/go-resty/resty/v2" "github.com/tidwall/gjson" + "net/http" "strings" "time" ) @@ -187,7 +188,19 @@ func (hc *HttpClient) Request() *define.Response { hc.fillResponseHeader(response) hc.fillResponseCookie(response) hc.fillResponseBody(response) + if response.HttpCode != http.StatusOK { + response.FailInfo = &define.ResponseFailInfo{ + Type: define.RequestFailTypeServerError, + Message: "http code is " + response.HttpCodeStatus + ", not success", + } + time.Sleep(time.Duration(hc.reqConfig.RetryRule.RetryTimeInterval) * time.Millisecond) + continue + } if !hc.isCodeSuccess(response) { + response.FailInfo = &define.ResponseFailInfo{ + Type: define.RequestFailTypeBusinessError, + Message: "business code is " + response.Code + ", not success", + } time.Sleep(time.Duration(hc.reqConfig.RetryRule.RetryTimeInterval) * time.Millisecond) continue }