From f320b642cb0aff0a72ee1273ad5c41a7a6d306d3 Mon Sep 17 00:00:00 2001 From: Beeno Tung Date: Mon, 19 Dec 2022 07:59:37 +0800 Subject: [PATCH] fix [DEP0005] DeprecationWarning Buffer() is deprecated due to security and usability issues. It is suggested to use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. Also discussed in https://github.com/spdy-http2/http-deceiver/pull/5 --- lib/deceiver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/deceiver.js b/lib/deceiver.js index a249571..8e18d07 100644 --- a/lib/deceiver.js +++ b/lib/deceiver.js @@ -247,7 +247,7 @@ Deceiver.prototype.emitBody = function emitBody (buffer) { Deceiver.prototype._emitEmpty = function _emitEmpty () { // Emit data to force out handling of UPGRADE - var empty = new Buffer(0) + var empty = Buffer.alloc ? Buffer.alloc(0) : new Buffer(0) if (this.socket.ondata) { this.socket.ondata(empty, 0, 0) } else { this.socket.emit('data', empty) }