From fa48e67578a3c43f83c9e4e9339440e8dbbcf6f5 Mon Sep 17 00:00:00 2001 From: Mikeal Rogers Date: Sat, 4 Mar 2017 17:39:10 -0800 Subject: [PATCH] safe-buffer doesn't zero-fill by default, its just a polyfill. (#2578) --- lib/helpers.js | 2 +- lib/multipart.js | 2 +- lib/oauth.js | 2 +- package.json | 2 +- request.js | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/helpers.js b/lib/helpers.js index 9e2d2ad34..05c77a0bd 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -36,7 +36,7 @@ function isReadStream (rs) { } function toBase64 (str) { - return (new Buffer(str || '', 'utf8')).toString('base64') + return Buffer.from(str || '', 'utf8').toString('base64') } function copy (obj) { diff --git a/lib/multipart.js b/lib/multipart.js index 4bb15325f..fc7b50276 100644 --- a/lib/multipart.js +++ b/lib/multipart.js @@ -72,7 +72,7 @@ Multipart.prototype.build = function (parts, chunked) { if (typeof part === 'number') { part = part.toString() } - return chunked ? body.append(part) : body.push(new Buffer(part)) + return chunked ? body.append(part) : body.push(Buffer.from(part)) } if (self.request.preambleCRLF) { diff --git a/lib/oauth.js b/lib/oauth.js index 402c89ff5..13b693773 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -71,7 +71,7 @@ OAuth.prototype.buildBodyHash = function(_oauth, body) { shasum.update(body || '') var sha1 = shasum.digest('hex') - return new Buffer(sha1).toString('base64') + return Buffer.from(sha1).toString('base64') } OAuth.prototype.concatParams = function (oa, sep, wrap) { diff --git a/package.json b/package.json index e64da627d..74c47ff6c 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "safe-buffer": "^5.0.1", "stringstream": "~0.0.4", "tough-cookie": "~2.3.0", - "tunnel-agent": "^0.5.0", + "tunnel-agent": "^0.6.0", "uuid": "^3.0.0" }, "scripts": { diff --git a/request.js b/request.js index 089d52813..467524ba4 100644 --- a/request.js +++ b/request.js @@ -418,7 +418,7 @@ Request.prototype.init = function (options) { function setContentLength () { if (isTypedArray(self.body)) { - self.body = new Buffer(self.body) + self.body = Buffer.from(self.body) } if (!self.hasHeader('content-length')) { @@ -1166,7 +1166,7 @@ Request.prototype.readResponseBody = function (response) { } debug('emitting complete', self.uri.href) if (typeof response.body === 'undefined' && !self._json) { - response.body = self.encoding === null ? new Buffer(0) : '' + response.body = self.encoding === null ? Buffer.alloc(0) : '' } self.emit('complete', response, response.body) })