title: Node.js - Create a proxy, why is request.pipe needed?
body: <p>Can some one explain this code to create a proxy server.  Everything makes sense except the last block.  request.pipe(proxy  - I don't get that because when proxy is declared it makes a request and pipes its response to the clients response.  What am I missing here?  Why would we need to pipe the original request to the proxy because the http.request method already makes the request contained in the options var.  </p>
  
  <pre><code>var http = require('http');
  
  function onRequest(request, response) {
      console.log('serve: ' + request.url);
  
      var options = {
          hostname: 'www.google.com',
          port: 80,
          path: request.url,
          method: 'GET'
      };
  
      var proxy = http.request(options, function (res) {
          res.pipe(response, {
              end: true
          });
      });
  
      request.pipe(proxy, {
          end: true
      });
  }
  
  http.createServer(onRequest).listen(8888);
  </code></pre>