diff options
author | isaacs <i@izs.me> | 2014-03-19 09:25:40 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2014-03-19 09:26:05 -0700 |
commit | a65c1aaf3afe21a34cae7b4ad266a6f2723704d1 (patch) | |
tree | 61e4c2a3b069f78d8ef5ae635a887cda13ec1c15 /deps/npm/node_modules/npm-registry-client/lib | |
parent | 43a29f53ca11ab48e1d1ef6b2a0e673ae43a42a0 (diff) | |
download | node-npm-1.4.6.tar.gz |
npm: upgrade to 1.4.6npm-1.4.6
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/lib')
-rw-r--r-- | deps/npm/node_modules/npm-registry-client/lib/adduser.js | 5 | ||||
-rw-r--r-- | deps/npm/node_modules/npm-registry-client/lib/request.js | 19 |
2 files changed, 20 insertions, 4 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/lib/adduser.js b/deps/npm/node_modules/npm-registry-client/lib/adduser.js index aebf71d67..a4581a6c8 100644 --- a/deps/npm/node_modules/npm-registry-client/lib/adduser.js +++ b/deps/npm/node_modules/npm-registry-client/lib/adduser.js @@ -24,8 +24,7 @@ function adduser (username, password, email, cb) { var salt = crypto.randomBytes(30).toString('hex') , userobj = { name : username - , salt : salt - , password_sha : sha(password + salt) + , password : password , email : email , _id : 'org.couchdb.user:'+username , type : "user" @@ -51,7 +50,7 @@ function adduser (username, password, email, cb) { cb = done.call(this, cb, pre) var logObj = Object.keys(userobj).map(function (k) { - if (k === 'salt' || k === 'password_sha') return [k, 'XXXXX'] + if (k === 'password') return [k, 'XXXXX'] return [k, userobj[k]] }).reduce(function (s, kv) { s[kv[0]] = kv[1] diff --git a/deps/npm/node_modules/npm-registry-client/lib/request.js b/deps/npm/node_modules/npm-registry-client/lib/request.js index b2cff11a7..c11dc9ca3 100644 --- a/deps/npm/node_modules/npm-registry-client/lib/request.js +++ b/deps/npm/node_modules/npm-registry-client/lib/request.js @@ -1,6 +1,7 @@ module.exports = regRequest var url = require("url") + , zlib = require("zlib") , fs = require("graceful-fs") , rm = require("rimraf") , asyncMap = require("slide").asyncMap @@ -128,6 +129,7 @@ function makeRequest (method, remote, where, what, etag, nofollow, cb_) { if (strict === undefined) strict = true var opts = { url: remote , method: method + , encoding: null // tell request let body be Buffer instance , ca: this.conf.get('ca') , localAddress: this.conf.get('local-address') , cert: this.conf.get('cert') @@ -140,6 +142,7 @@ function makeRequest (method, remote, where, what, etag, nofollow, cb_) { } headers.accept = "application/json" + headers['accept-encoding'] = 'gzip' headers["user-agent"] = this.conf.get('user-agent') || 'node/' + process.version @@ -170,7 +173,7 @@ function makeRequest (method, remote, where, what, etag, nofollow, cb_) { this.log.http(method, remote.href || "/") var done = requestDone.call(this, method, where, cb) - var req = request(opts, done) + var req = request(opts, decodeResponseBody(done)) req.on("error", cb) req.on("socket", function (s) { @@ -182,6 +185,20 @@ function makeRequest (method, remote, where, what, etag, nofollow, cb_) { } } +function decodeResponseBody(cb) { + return function (er, response, data) { + if (er) return cb(er, response, data) + + if (response.headers['content-encoding'] !== 'gzip') return cb(er, response, data) + + zlib.gunzip(data, function (er, buf) { + if (er) return cb(er, response, data) + + cb(null, response, buf) + }) + } +} + // cb(er, parsed, raw, response) function requestDone (method, where, cb) { return function (er, response, data) { |