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 }