How to use the builder-util-runtime.createHttpError function in builder-util-runtime

To help you get started, we’ve selected a few builder-util-runtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electron-userland / electron-builder / packages / electron-updater / src / differentialDownloader / DifferentialDownloader.ts View on Github external
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) => {
github electron-userland / electron-builder / packages / electron-updater / src / differentialDownloader / multipleRangeDownloader.ts View on Github external
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
}