parent
e1b4460ebd
commit
bc2efe928a
|
|
@ -228,12 +228,14 @@ func setNTGToken(token string) {
|
||||||
|
|
||||||
func (ntg NTGVision) search(states []config.State) (io.ReadCloser, error) {
|
func (ntg NTGVision) search(states []config.State) (io.ReadCloser, error) {
|
||||||
if getNTGToken() == "" {
|
if getNTGToken() == "" {
|
||||||
|
logtr.Debugf("NTG token is empty, refreshing ntg auth")
|
||||||
if err := ntg.refreshAuth(); err != nil {
|
if err := ntg.refreshAuth(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rc, err := ntg._search(states)
|
rc, err := ntg._search(states)
|
||||||
if err == ErrNoAuth {
|
if err == ErrNoAuth {
|
||||||
|
logtr.Debugf("err no auth on search, refreshing ntg auth")
|
||||||
if err := ntg.refreshAuth(); err != nil {
|
if err := ntg.refreshAuth(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -295,7 +297,9 @@ func (ntg NTGVision) _search(states []config.State) (io.ReadCloser, error) {
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
b, _ := ioutil.ReadAll(resp.Body)
|
b, _ := ioutil.ReadAll(resp.Body)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
if resp.StatusCode > 400 && resp.StatusCode < 500 && resp.StatusCode != 404 && resp.StatusCode != 410 {
|
logtr.Warnf("ntg auth bad status: url=%s, status=%v, body=%s", request.URL.String(), resp.StatusCode, b)
|
||||||
|
if resp.StatusCode > 400 && resp.StatusCode < 404 {
|
||||||
|
logtr.Warnf("ntg auth bad status: err no auth")
|
||||||
return nil, ErrNoAuth
|
return nil, ErrNoAuth
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("bad status searching ntg: %d: %s", resp.StatusCode, b)
|
return nil, fmt.Errorf("bad status searching ntg: %d: %s", resp.StatusCode, b)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue