title: node express/request: piping a POST request with body parsing
body: <p>I'm attempting to pipe a request for handling by a remote server, along the following lines:</p>
  
  <pre><code>var destination = request(url);
  req.pipe(destination).pipe(res);
  </code></pre>
  
  <p>This works just fine for <code>GET</code> requests.  But for <code>POST</code> requests I'm struggling.  An important point to note, I think, is that for <code>POST</code> requests I'm using a body parser before my <code>POST</code> route handler in order to extract the body from the <code>POST</code> request... it's just a basic text body parser because the body contains plain text:</p>
  
  <pre><code>var postRouteHandler = someFunction;
  var bodyParser = require('body-parser');
  var textParser = bodyParser.text({
      limit: '50kb'
  });
  app.use('/postRoute', [textParser, postRouteHandler]);
  </code></pre>
  
  <p>From <a href="https://github.com/request/request/issues/1664" rel="noreferrer">this issue</a> and <a href="https://github.com/request/request/issues/1616" rel="noreferrer">this issue</a> it seems to me that doing any processing on the <code>POST</code> request before you pipe it will cause a problem.  Indeed, when I remove the parser, the piping seems to work OK.</p>
  
  <p>The problem is that I need to examine the body first, to do some initial processing and then to determine whether or not to pipe the request on to the remote server at all.  So I <em>need</em> to parse the body before piping.</p>
  
  <p>Is there any way around this problem?</p>