Created
July 30, 2012 01:05
-
-
Save nemtsov/3203083 to your computer and use it in GitHub Desktop.
first stab at wrapping the http.request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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