title: Saving Express request object to a file
body: <p>I'm trying to pipe Express request object to a writable stream. NodeJS creates a file, but it's empty. What am I missing? </p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>var express = require('express');
  var fs = require('fs');
  
  var app = express();
      app.use(middleWare);
      app.listen(3000);
  
  function middleWare(req, res, next){
      var ws = fs.createWriteStream('./test.txt');
      req.pipe(ws);
      res.sendStatus(200);
  }
  </code></pre>
  
  <p>When I replace <strong>req.pipe(ws)</strong> with <strong>ws.write(req)</strong> I get an error:</p>
  
  <pre><code> TypeError: Invalid non-string/buffer chunk
  </code></pre>
  
  <p>When I replace <strong>ws.write(req)</strong> with <strong>ws.write(JSON.stringify(req))</strong> I get an error:</p>
  
  <pre><code>  TypeError: Converting circular structure to JSON
  </code></pre>