How to use the follow-redirects.https function in follow-redirects

To help you get started, we’ve selected a few follow-redirects 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 daftspunk / pond / version2 / app / services / Provision / Downloader.js View on Github external
export async function downloadInstaller(websitePath) {
    const client = followRedirects.https;

    const tmpFilePath = makeTmpFileName('october-installer-archive');

    var options = config.installerDownloadOptions.wizard;

    await new Promise((resolve, reject) => {
        const file = fileSystem.createWriteStream(tmpFilePath);

        const request = client.get(options);

        file.on('error', (err) => {
            reject('Unable to save downloaded file');
        })

        request.on('error', (err) => {
            reject('Unable to download the installer: there was a network error. Please check your Internet connection.');
github unfoldingWord / translationCore / src / js / helpers / DownloadHelpers.js View on Github external
module.exports.download = (uri, dest, progressCallback) => {
  progressCallback = progressCallback || function () {};

  let parsedUrl = url.parse(uri, false, true);
  let makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
  let serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
  let agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;
  let file = fs.createWriteStream(dest);

  let options = {
    host: parsedUrl.host,
    path: parsedUrl.path,
    agent: agent,
    port: serverPort,
    method: 'GET',
  };

  return new Promise((resolve, reject) => {
    let req = makeRequest(options, (response) => {
      let size = response.headers['content-length'];
      let progress = 0;