Skip to content

Instantly share code, notes, and snippets.

@indexzero
Created May 9, 2012 21:04
Show Gist options
  • Select an option

  • Save indexzero/2648816 to your computer and use it in GitHub Desktop.

Select an option

Save indexzero/2648816 to your computer and use it in GitHub Desktop.
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');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment