mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 12:20:04 +02:00
update modules
This commit is contained in:
27
node_modules/ws/lib/receiver.js
generated
vendored
27
node_modules/ws/lib/receiver.js
generated
vendored
@@ -30,14 +30,17 @@ class Receiver extends Writable {
|
||||
*
|
||||
* @param {String} binaryType The type for binary data
|
||||
* @param {Object} extensions An object containing the negotiated extensions
|
||||
* @param {Boolean} isServer Specifies whether to operate in client or server
|
||||
* mode
|
||||
* @param {Number} maxPayload The maximum allowed message length
|
||||
*/
|
||||
constructor(binaryType, extensions, maxPayload) {
|
||||
constructor(binaryType, extensions, isServer, maxPayload) {
|
||||
super();
|
||||
|
||||
this._binaryType = binaryType || BINARY_TYPES[0];
|
||||
this[kWebSocket] = undefined;
|
||||
this._extensions = extensions || {};
|
||||
this._isServer = !!isServer;
|
||||
this._maxPayload = maxPayload | 0;
|
||||
|
||||
this._bufferedBytes = 0;
|
||||
@@ -65,6 +68,7 @@ class Receiver extends Writable {
|
||||
* @param {Buffer} chunk The chunk of data to write
|
||||
* @param {String} encoding The character encoding of `chunk`
|
||||
* @param {Function} cb Callback
|
||||
* @private
|
||||
*/
|
||||
_write(chunk, encoding, cb) {
|
||||
if (this._opcode === 0x08 && this._state == GET_INFO) return cb();
|
||||
@@ -96,11 +100,12 @@ class Receiver extends Writable {
|
||||
|
||||
do {
|
||||
const buf = this._buffers[0];
|
||||
const offset = dst.length - n;
|
||||
|
||||
if (n >= buf.length) {
|
||||
this._buffers.shift().copy(dst, dst.length - n);
|
||||
dst.set(this._buffers.shift(), offset);
|
||||
} else {
|
||||
buf.copy(dst, dst.length - n, 0, n);
|
||||
dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
|
||||
this._buffers[0] = buf.slice(n);
|
||||
}
|
||||
|
||||
@@ -117,7 +122,7 @@ class Receiver extends Writable {
|
||||
* @private
|
||||
*/
|
||||
startLoop(cb) {
|
||||
var err;
|
||||
let err;
|
||||
this._loop = true;
|
||||
|
||||
do {
|
||||
@@ -224,6 +229,16 @@ class Receiver extends Writable {
|
||||
if (!this._fin && !this._fragmented) this._fragmented = this._opcode;
|
||||
this._masked = (buf[1] & 0x80) === 0x80;
|
||||
|
||||
if (this._isServer) {
|
||||
if (!this._masked) {
|
||||
this._loop = false;
|
||||
return error(RangeError, 'MASK must be set', true, 1002);
|
||||
}
|
||||
} else if (this._masked) {
|
||||
this._loop = false;
|
||||
return error(RangeError, 'MASK must be clear', true, 1002);
|
||||
}
|
||||
|
||||
if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16;
|
||||
else if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64;
|
||||
else return this.haveLength();
|
||||
@@ -320,7 +335,7 @@ class Receiver extends Writable {
|
||||
* @private
|
||||
*/
|
||||
getData(cb) {
|
||||
var data = EMPTY_BUFFER;
|
||||
let data = EMPTY_BUFFER;
|
||||
|
||||
if (this._payloadLength) {
|
||||
if (this._bufferedBytes < this._payloadLength) {
|
||||
@@ -400,7 +415,7 @@ class Receiver extends Writable {
|
||||
this._fragments = [];
|
||||
|
||||
if (this._opcode === 2) {
|
||||
var data;
|
||||
let data;
|
||||
|
||||
if (this._binaryType === 'nodebuffer') {
|
||||
data = concat(fragments, messageLength);
|
||||
|
Reference in New Issue
Block a user