fix(xunlei): check err prevent stack overflow

pull/984/head
Xhofe 2022-04-18 18:29:21 +08:00
parent d38f36ef44
commit 0810561a8a
1 changed files with 9 additions and 3 deletions

View File

@ -245,12 +245,18 @@ func (s *State) Request(method string, url string, callback func(*resty.Request)
log.Debug(res.String())
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 {
case 9:
s.newCaptchaToken(getAction(method, url), nil, account)
_, err = s.newCaptchaToken(getAction(method, url), nil, account)
if err != nil {
return nil, err
}
fallthrough
case 4122, 4121:
case 4122, 4121: // Authorization expired
return s.Request(method, url, callback, account)
case 0:
if res.StatusCode() == http.StatusOK {