title: How to detect client closing connection during piping stream over http in node?
body: <p>I stream data from server to client in an expressjs (nodejs) application.</p>
  
  <p>I do something like this;</p>
  
  <pre><code>// let contentType and filename be correctly defined in context
  
  function(req,res){
      res.setHeader('Content-Type',contentType);
      res.setHeader('Content-Disposition','attachment; filename='+filename);
      require('fs').createReadStream('/path/file').pipe(res);
  }
  </code></pre>
  
  <p>I would want to know when the client fails to download the file, but I don't get how to proceed.</p>