indexzero
5/9/2012 - 9:04 PM

Calculating proxy-time with node-http-proxy

Calculating proxy-time with node-http-proxy

var http = require('http'),
    httpProxy = require('http-proxy');

var proxy = new httpProxy.HttpProxy({
  host: 'somewhere.on.theinternet.com'
  port: 80
});

http.createServer(function (req, res) {
  req.start = +new Date();

  proxy.proxyRequest(req, res);
}).listen(8080);

proxy.on('end', function (req, res) {
  var now = (+new Date());

  console.log('Proxy from ' + req.url);
  console.log('Completed on ' + now + ' in ' + (now - req.start) + 'ms');
});