title: Download GitLab repository archive using GitLab API and Node.js
body: <p>I would like to download (not clone) archive from my GitLab repository, but I get this error </p>
  
  <blockquote>
    <p>incorrect header check (Zlib._handle.onerror)</p>
  </blockquote>
  
  <p>This is my function:</p>
  
  <pre><code>var fs = require('fs');
  var url = require('url');
  var https = require('https');
  var path = require('path');
  var targz = require('tar.gz');
  
  function downloadFile(source, destination, name) {
      var options = {
          host: url.parse(source).host,
          port: 443,
          path: url.parse(source).pathname
      };
  
      var file = fs.createWriteStream(destination + path.sep + name);
  
      https.get(options, function(res) {
          res.on('data', function(data) {
              file.write(data);
          }).on('end', function() {
              file.end();
              console.log('File ' + name + ' downloaded to ' + destination);
  
              targz().extract(destination + '/' + name, destination)
                  .then(function(){
                      console.log('Job done!');
                  })
                  .catch(function(err){
                      console.log('Something is wrong ', err.stack);
                  });
          });
      });
  }
  </code></pre>
  
  <p>The file which is download is type of tar.gz. I try to set some headers but unsuccessful. Source param is like: <a href="https://gitlab.com/api/v3/projects/:ID/repository/archive?token=XXYYZZ" rel="nofollow noreferrer">https://gitlab.com/api/v3/projects/:ID/repository/archive?token=XXYYZZ</a></p>
  
  <p>Any help please?</p>