Skip to content

Instantly share code, notes, and snippets.

@nemtsov
Created July 30, 2012 01:05
Show Gist options
  • Save nemtsov/3203083 to your computer and use it in GitHub Desktop.
Save nemtsov/3203083 to your computer and use it in GitHub Desktop.
first stab at wrapping the http.request
var http = require('http')
, util = require('util');
var CR = http.ClientRequest;
function StatsClientRequest(options, cb) {
CR.call(this, options, cb);
var before = (new Date).getTime();
this.once('response', function (res) {
res.on('end', function () {
var total = ((new Date).getTime() - before);
console.log('[req] href=' + res.request.href + ', time=' + total);
});
});
};
util.inherits(StatsClientRequest, CR);
http.ClientRequest = StatsClientRequest;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment