Skip to content

boennemann/http-request-timings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-request-timings

Build Status Coverage Status Dependency Status devDependency Status js-standard-style

NPM

This module monkey-patches the http.request method – which is used internally by http.get, https.request, https.get and therefor any library like request – to record timings.

Note: The core https module isn't patched on node <=0.10. This will be addressed in a future version.

npm install -S http-request-timings
var http = require('http')

var timings = require('http-request-timings')

// monkey-patch http.request
timings.start()

timings.on('timing', function (timing, options, res) {
  timing.start // Date
  timing.firstByte // Date
  timing.end // Date

  timing.timeToFirstByte // duration in ms
  timing.timeToEnd // duration in ms

  // options passed to http.request
  // if it was originally a string then it's `url.parse`d
  options

  // the response
  res
})

http.get('http://example.com/', function (res) {
  // …
  res.on('data', doStuff)

  // go back to default http.request
  timings.stop()
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published