Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
!isStream && (
res.status === 408 || // Request Timeout
res.status === 420 || // Enhance Your Calm (usually Twitter rate-limit)
res.status === 429 || // Too Many Requests ("standard" rate-limiting)
res.status >= 500 // Assume server errors are momentary hiccups
)
if (isRetriable) {
if (typeof opts.onRetry === 'function') {
opts.onRetry(res)
}
return retryHandler(res)
}
if (!fetch.isRedirect(res.status) || opts.redirect === 'manual') {
return res
}
// handle redirects - matches behavior of npm-fetch: https://github.com/bitinn/node-fetch
if (opts.redirect === 'error') {
const err = new Error(`redirect mode is set to error: ${uri}`)
err.code = 'ENOREDIRECT'
throw err
}
if (!res.headers.get('location')) {
const err = new Error(`redirect location header missing at: ${uri}`)
err.code = 'EINVALIDREDIRECT'
throw err
}