title: Serving tar.gz file and download it on nodejs
body: <p>I have tar.gz file on a nodejs server. I want it to be downloadable from another nodejs app. I can do it with txt, jpeg etc... But no success with tar.gz. When I download the tar.gz file seems empty on the client.</p>
  
  <p><strong>This is the simplified basic server that I used</strong></p>
  
  <pre><code>var http = require('http');
  
  http.createServer(function(request, response){
  
  fs.readFile(__dirname + "/update/test.tar.gz", (err, data) =&gt; {
       if (err) {
  
       } else {
  
           response.setHeader('Content-Type', 'application/x-gzip');
           response.end(data);
       }
  });
  </code></pre>
  
  <p><strong>This is the client that tries to download</strong> </p>
  
  <pre><code>var postData = {};
  
  var options = {
      protocol : "http:",
      host: "localhost",
      port: 3010,
      path: '/GetFile',
      method: 'POST',
      headers: {
          'Content-Type': 'application/octet-stream',
          'Content-Length': Buffer.byteLength(postData)
      }
  };
  
  var req = http.request(options, function(res) {
  
      var body = '';
  
      res.on('data', function (chunk) {
  
          body += chunk;
      });
  
      res.on('end', function(){
  
          fs.writeFile("./test4.tar.gz", body, function(err) {
  
          });
  
  
      });
  });
  
  req.write(postData);
  req.end();
  </code></pre>
  
  <p>It seems saving file successfully but I cant extract it.</p>