title: PDF File downloads incorrectly in browser, but fine with wget or curl with NodeJS/Express
body: <p>I have an application in nodejs/express that generates a PDF and streams it in the response. When I perform a request via curl or wget the file downloads just fine.</p>
  
  <p>When I perform the request on a browser, the file is not downloaded correctly. Curiosly, the file size is way bigger (is 59k when downloaded with wget/curl but 101k when downloaded in the browser)</p>
  
  <p>Here's the snippet that generates the response:</p>
  
  <pre><code>fs.readFile('file.pdf', function(err, data) {
    res.setHeader('Content-Disposition', 'attachment; filename=' + req.params.id + '.pdf');
    res.setHeader('Content-Type', 'application/pdf');                
    res.setHeader('Content-Length', data.length);
    res.status(200).end(data);
  });
  </code></pre>
  
  <p>I don't know if I'm missing a header or if there's something in the request that I should be paying attention to that I'm not, but I have no idea why this is happening. Any ideas?</p>