Skip to content

Commit

Permalink
safe-buffer doesn't zero-fill by default, its just a polyfill. (#2578)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Mar 5, 2017
1 parent 2e70b74 commit fa48e67
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/helpers.js
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/multipart.js
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/oauth.js
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions request.js
Expand Up @@ -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')) {
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit fa48e67

Please sign in to comment.