Check HTTP error codes

This commit is contained in:
Frank Denis 2018-01-18 23:31:14 +01:00
parent a85d012a2b
commit f745eb578a
1 changed files with 4 additions and 0 deletions

View File

@ -62,6 +62,9 @@ func fetchWithCache(url string, cacheFile string, refreshDelay time.Duration) (i
var resp *http.Response
dlog.Infof("Loading source information from URL [%s]", url)
resp, err = http.Get(url)
if resp.StatusCode < 200 || resp.StatusCode > 299 {
err = fmt.Errorf("Webserver returned code %d", resp.StatusCode)
}
if err != nil {
delayTillNextUpdate = SourcesUpdateDelayAfterFailure
if usableCache {
@ -85,6 +88,7 @@ func fetchWithCache(url string, cacheFile string, refreshDelay time.Duration) (i
}
}
}
err = nil
in = string(bin)
return
}