Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const request = this.httpExecutor.createRequest(requestOptions, response => {
// Electron net handles redirects automatically, our NodeJS test server doesn't use redirects - so, we don't check 3xx codes.
if (response.statusCode >= 400) {
reject(createHttpError(response))
}
response.pipe(firstStream, {
end: false
})
response.once("end", () => {
if (++downloadOperationCount === 100) {
downloadOperationCount = 0
setTimeout(() => w(index), 1000)
}
else {
w(index)
}
})
})
request.on("redirect", (statusCode: number, method: string, redirectUrl: string) => {
export function checkIsRangesSupported(response: IncomingMessage, reject: (error: Error) => void): boolean {
// Electron net handles redirects automatically, our NodeJS test server doesn't use redirects - so, we don't check 3xx codes.
if (response.statusCode!! >= 400) {
reject(createHttpError(response))
return false
}
if (response.statusCode !== 206) {
const acceptRanges = safeGetHeader(response, "accept-ranges")
if (acceptRanges == null || acceptRanges === "none") {
reject(new Error(`Server doesn't support Accept-Ranges (response code ${response.statusCode})`))
return false
}
}
return true
}