Add http response code 503 to check.

This commit is contained in:
Jianfei Bai 2019-08-13 16:01:01 +08:00
parent b5dfcf357a
commit 1d75a16b46

View File

@ -129,7 +129,10 @@ func newWalkFunc(invalidLink *bool, client *http.Client) filepath.WalkFunc {
if err != nil {
break
}
if resp.StatusCode == http.StatusTooManyRequests {
// This header is used in 301, 429 and 503.
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
// And Go client will follow redirects automatically so the 301 check is probably unnecessary.
if resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode == http.StatusServiceUnavailable {
retryAfter := resp.Header.Get("Retry-After")
if seconds, err := strconv.Atoi(retryAfter); err != nil {
backoff = seconds + 10