fix 301 response missing Location header error

This commit is contained in:
eatMoreApple 2021-05-14 00:11:29 +08:00
parent 15855ca0f2
commit 4fa5d04fb4
2 changed files with 243 additions and 237 deletions

View File

@ -85,6 +85,10 @@ func (c *Caller) GetLoginInfo(body []byte) (*LoginInfo, error) {
resp := NewReturnResponse(c.Client.GetLoginInfo(path.String()))
if resp.Err() != nil {
uErr, ok := resp.Err().(*url.Error)
if ok && (uErr.Err.Error() == missLocationHeader.Error()) {
return nil, loginForbiddenError
}
return nil, resp.Err()
}
defer resp.Body.Close()

View File

@ -51,6 +51,8 @@ const (
// errors
var (
noSuchUserFoundError = errors.New("no such user found")
missLocationHeader = errors.New("301 response missing Location header")
loginForbiddenError = errors.New("login forbidden")
)
// ALL跟search函数搭配