nodejs-websocket
Advanced tools
Comparing version 1.7.1 to 1.7.2
@@ -58,3 +58,3 @@ /** | ||
this.readyState = this.CONNECTING | ||
this.buffer = new Buffer(0) | ||
this.buffer = Buffer.alloc(0) | ||
this.frameBuffer = null // string for text frames and InStream for binary frames | ||
@@ -272,3 +272,3 @@ this.outStream = null // current allocated OutStream object for sending binary frames | ||
var str, i, key, headers, header | ||
key = new Buffer(16) | ||
key = Buffer.alloc(16) | ||
for (i = 0; i < 16; i++) { | ||
@@ -392,3 +392,3 @@ key[i] = Math.floor(Math.random() * 256) | ||
if (this.headers.upgrade.toLowerCase() !== 'websocket' || | ||
this.headers.connection.toLowerCase().split(', ').indexOf('upgrade') === -1) { | ||
this.headers.connection.toLowerCase().split(/\s*,\s*/).indexOf('upgrade') === -1) { | ||
this.emit('error', new Error('Invalid handshake: invalid Upgrade or Connection header')) | ||
@@ -456,3 +456,3 @@ return false | ||
if (this.headers.upgrade.toLowerCase() !== 'websocket' || | ||
this.headers.connection.toLowerCase().split(', ').indexOf('upgrade') === -1) { | ||
this.headers.connection.toLowerCase().split(/\s*,\s*/).indexOf('upgrade') === -1) { | ||
return false | ||
@@ -459,0 +459,0 @@ } |
16
frame.js
@@ -16,3 +16,3 @@ /** | ||
payload = new Buffer(data) | ||
payload = Buffer.from(data) | ||
meta = generateMetaData(true, 1, masked === undefined ? false : masked, payload) | ||
@@ -38,3 +38,3 @@ | ||
if (masked) { | ||
payload = new Buffer(data.length) | ||
payload = Buffer.alloc(data.length) | ||
data.copy(payload) | ||
@@ -61,6 +61,6 @@ } else { | ||
if (code !== undefined && code !== 1005) { | ||
payload = new Buffer(reason === undefined ? '--' : '--' + reason) | ||
payload = Buffer.from(reason === undefined ? '--' : '--' + reason) | ||
payload.writeUInt16BE(code, 0) | ||
} else { | ||
payload = new Buffer(0) | ||
payload = Buffer.alloc(0) | ||
} | ||
@@ -82,3 +82,3 @@ meta = generateMetaData(true, 8, masked === undefined ? false : masked, payload) | ||
payload = new Buffer(data) | ||
payload = Buffer.from(data) | ||
meta = generateMetaData(true, 9, masked === undefined ? false : masked, payload) | ||
@@ -99,3 +99,3 @@ | ||
payload = new Buffer(data) | ||
payload = Buffer.from(data) | ||
meta = generateMetaData(true, 10, masked === undefined ? false : masked, payload) | ||
@@ -122,3 +122,3 @@ | ||
// Creates the buffer for meta-data | ||
meta = new Buffer(2 + (len < 126 ? 0 : (len < 65536 ? 2 : 8)) + (masked ? 4 : 0)) | ||
meta = Buffer.alloc(2 + (len < 126 ? 0 : (len < 65536 ? 2 : 8)) + (masked ? 4 : 0)) | ||
@@ -147,3 +147,3 @@ // Sets fin and opcode | ||
if (masked) { | ||
mask = new Buffer(4) | ||
mask = Buffer.alloc(4) | ||
for (i = 0; i < 4; i++) { | ||
@@ -150,0 +150,0 @@ meta[start + i] = mask[i] = Math.floor(Math.random() * 256) |
@@ -0,1 +1,6 @@ | ||
# 1.7.2 | ||
* Fixed: parsing error when `Connection` header uses ',' instead of ', ' (with space) [#46](https://github.com/sitegui/nodejs-websocket/pull/46) | ||
* Fixed: uses Buffer.alloc and Buffer.from instead of new Buffer | ||
* Changed: Drop support for Node v0.12 | ||
# 1.7.1 | ||
@@ -2,0 +7,0 @@ * Fixed: two errors were emitted when trying to sendText to a closed connection while there was another pending binary write operation. |
@@ -0,0 +0,0 @@ 'use strict' |
@@ -0,0 +0,0 @@ /** |
@@ -19,3 +19,3 @@ /** | ||
this.minSize = minSize | ||
this.buffer = new Buffer(0) | ||
this.buffer = Buffer.alloc(0) | ||
this.hasSent = false // Indicates if any frame has been sent yet | ||
@@ -52,3 +52,3 @@ stream.Writable.call(this) | ||
} | ||
this.buffer = new Buffer(0) | ||
this.buffer = Buffer.alloc(0) | ||
this.hasSent = true | ||
@@ -55,0 +55,0 @@ if (this.connection.readyState !== this.connection.OPEN) { |
{ | ||
"name": "nodejs-websocket", | ||
"version": "1.7.1", | ||
"version": "1.7.2", | ||
"author": "Sitegui <sitegui@sitegui.com.br>", | ||
@@ -18,3 +18,3 @@ "description": "Basic server&client approach to websocket (text and binary frames)", | ||
"engines": { | ||
"node": ">=0.10" | ||
"node": ">=4" | ||
}, | ||
@@ -25,5 +25,5 @@ "scripts": { | ||
"devDependencies": { | ||
"mocha": "^3.0.2", | ||
"should": "^11.1.0" | ||
"mocha": "^5.2.0", | ||
"should": "^13.2.3" | ||
} | ||
} | ||
} |
@@ -186,3 +186,3 @@ # Nodejs Websocket | ||
// Empty buffer for collecting binary data | ||
var data = new Buffer(0) | ||
var data = Buffer.alloc(0) | ||
// Read chunks of binary data and add to the buffer | ||
@@ -189,0 +189,0 @@ inStream.on("readable", function () { |
@@ -0,0 +0,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43635
12