lib/middlewares/forward.js
function forward(){
  return function forward(req, res, next){
    var url  = utils.processUrl(req);
    var options = {
      url: url,
      method: req.method,
      headers: req.headers
    }
    var buffers = [];

    log.debug('forward: ' + url);
    
    if(req.method === 'POST'){
      req.on('data', function(chunk){
        buffers.push(chunk);
      });

      req.on('end', function(){
        options.data = Buffer.concat(buffers);
        utils.request(options, function(err, data, proxyRes){
          _forwardHandler(err, data, proxyRes, res);
        });
      });
    }else{
      utils.request(options, function(err, data, proxyRes){
        _forwardHandler(err, data, proxyRes, res)
      }); 
    }
  };
}
function forward(){
  return function forward(req, res, next){
    var url  = utils.processUrl(req);
    var options = {
      url: url,
      method: req.method,
      headers: req.headers
    }
    var buffers = [];

    log.debug('forward: ' + url);
    
    if(req.method === 'POST'){
      req.on('data', function(chunk){
        buffers.push(chunk);
      });

      req.on('end', function(){
        options.data = Buffer.concat(buffers);
        utils.request(options, function(err, data, proxyRes){
          _forwardHandler(err, data, proxyRes, res);
        });
      });
    }else{
      utils.request(options, function(err, data, proxyRes){
        _forwardHandler(err, data, proxyRes, res)
      }); 
    }
  };
}
function forward ( ) { return function forward ( req , res , next ) { var url = utils . processUrl ( req ) ; var options = { url : url , method : req . method , headers : req . headers } var buffers = [ ] ; log . debug ( 'forward: ' + url ) ; if ( req . method === 'POST' ) { req . on ( 'data' , function ( chunk ) { buffers . push ( chunk ) ; } ) ; req . on ( 'end' , function ( ) { options . data = Buffer . concat ( buffers ) ; utils . request ( options , function ( err , data , proxyRes ) { _forwardHandler ( err , data , proxyRes , res ) ; } ) ; } ) ; } else { utils . request ( options , function ( err , data , proxyRes ) { _forwardHandler ( err , data , proxyRes , res ) } ) ; } } ; }
Forward the request directly
Forward the request directly