fix(xunlei): check err prevent stack overflow

This commit is contained in:
Xhofe 2022-04-18 18:29:21 +08:00
parent d38f36ef44
commit 0810561a8a

View File

@ -245,12 +245,18 @@ func (s *State) Request(method string, url string, callback func(*resty.Request)
log.Debug(res.String()) log.Debug(res.String())
var e Erron var e Erron
utils.Json.Unmarshal(res.Body(), &e) err = utils.Json.Unmarshal(res.Body(), &e)
if err != nil {
return nil, err
}
switch e.ErrorCode { switch e.ErrorCode {
case 9: case 9:
s.newCaptchaToken(getAction(method, url), nil, account) _, err = s.newCaptchaToken(getAction(method, url), nil, account)
if err != nil {
return nil, err
}
fallthrough fallthrough
case 4122, 4121: case 4122, 4121: // Authorization expired
return s.Request(method, url, callback, account) return s.Request(method, url, callback, account)
case 0: case 0:
if res.StatusCode() == http.StatusOK { if res.StatusCode() == http.StatusOK {