Skip to content

Instantly share code, notes, and snippets.

@trentm
Created June 28, 2012 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trentm/3007823 to your computer and use it in GitHub Desktop.
Save trentm/3007823 to your computer and use it in GitHub Desktop.
onResponse is gone
Index: /Users/trentm/tm/npm/lib/utils/fetch.js
index f69975b..2962cf9 100644
--- a/lib/utils/fetch.js
+++ b/lib/utils/fetch.js
@@ -55,14 +55,16 @@ function makeRequest (remote, fstr, headers) {
? "https-proxy"
: "proxy")
- request({ url: remote
+ var req = request({ url: remote
, proxy: proxy
, strictSSL: npm.config.get("strict-ssl")
, ca: remote.host === regHost ? npm.config.get("ca") : undefined
- , headers: { "user-agent": npm.config.get("user-agent") }
- , onResponse: onResponse }).pipe(fstr)
- function onResponse (er, res) {
- if (er) return fstr.emit("error", er)
+ , headers: { "user-agent": npm.config.get("user-agent") }})
+ req.on('error', function (er) {
+ fstr.emit("error", er)
+ })
+ req.on('response', function (res) {
log.http(res.statusCode, remote.href)
- }
+ })
+ req.pipe(fstr)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment