How to use the builder-util-runtime.configureRequestOptions 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
createRequestOptions(): RequestOptions {
    const result = {
      headers: {
        ...this.options.requestHeaders,
        accept: "*/*",
      },
    }
    configureRequestUrl(this.options.newUrl, result)
    // user-agent, cache-control and other common options
    configureRequestOptions(result)
    return result
  }
github electron-userland / electron-builder / packages / electron-updater / src / electronHttpExecutor.ts View on Github external
return await options.cancellationToken.createPromise((resolve, reject, onCancel) => {
      const requestOptions = {
        headers: options.headers || undefined,
        redirect: "manual",
      }
      configureRequestUrl(url, requestOptions)
      configureRequestOptions(requestOptions)
      this.doDownload(requestOptions, {
        destination,
        options,
        onCancel,
        callback: error => {
          if (error == null) {
            resolve(destination)
          }
          else {
            reject(error)
          }
        },
        responseHandler: null,
      }, 0)
    })
  }
github electron-userland / electron-builder / packages / app-builder-lib / src / publish / BintrayPublisher.ts View on Github external
"X-Bintray-Publish": "1",
        "X-Bintray-Debian-Architecture": toLinuxArchString(arch, "deb")
      }
    }

    if (this.client.distribution != null) {
      options.headers!!["X-Bintray-Debian-Distribution"] = this.client.distribution
    }

    if (this.client.component != null) {
      options.headers!!["X-Bintray-Debian-Component"] = this.client.component
    }

    for (let attemptNumber = 0; ; attemptNumber++) {
      try {
        return await httpExecutor.doApiRequest(configureRequestOptions(options, this.client.auth), this.context.cancellationToken, requestProcessor)
      }
      catch (e) {
        if (attemptNumber < 3 && ((e instanceof HttpError && e.statusCode === 502) || e.code === "EPIPE")) {
          continue
        }

        throw e
      }
    }
  }
github electron-userland / electron-builder / packages / electron-publish / src / gitHubPublisher.ts View on Github external
private doUploadFile(attemptNumber: number, parsedUrl: UrlWithStringQuery, fileName: string, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, release: any): Promise {
    return httpExecutor.doApiRequest(configureRequestOptions({
      hostname: parsedUrl.hostname,
      path: parsedUrl.path,
      method: "POST",
      headers: {
        accept: "application/vnd.github.v3+json",
        "Content-Type": mime.getType(fileName) || "application/octet-stream",
        "Content-Length": dataLength
      }
    }, this.token), this.context.cancellationToken, requestProcessor)
      .catch(e => {
        if ((e as any).statusCode === 422 && e.description != null && e.description.errors != null && e.description.errors[0].code === "already_exists") {
          return this.overwriteArtifact(fileName, release)
            .then(() => this.doUploadFile(attemptNumber, parsedUrl, fileName, dataLength, requestProcessor, release))
        }

        if (attemptNumber > 3) {