Skip to content

Commit 0f3fbf3

Browse files
committed
fix 4 autobahn tests
1 parent 388fe56 commit 0f3fbf3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/web/websocket/receiver.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class ByteParser extends Writable {
110110

111111
if (isControlFrame(opcode)) {
112112
const loop = this.parseControlFrame(callback, {
113+
header: buffer,
113114
opcode,
114115
fragmented,
115116
payloadLength
@@ -122,6 +123,7 @@ class ByteParser extends Writable {
122123
}
123124
} else if (isContinuationFrame(opcode)) {
124125
const loop = this.parseContinuationFrame(callback, {
126+
header: buffer,
125127
fin,
126128
fragmented,
127129
payloadLength
@@ -297,7 +299,7 @@ class ByteParser extends Writable {
297299
* Parses control frames.
298300
* @param {Buffer} data
299301
* @param {(err?: Error) => void} callback
300-
* @param {{ opcode: number, fragmented: boolean, payloadLength: number }} info
302+
* @param {{ opcode: number, fragmented: boolean, payloadLength: number, header: Buffer }} info
301303
*/
302304
parseControlFrame (callback, info) {
303305
assert(!info.fragmented)
@@ -307,6 +309,9 @@ class ByteParser extends Writable {
307309
failWebsocketConnection(this.ws, 'Payload length for control frame exceeded 125 bytes.')
308310
return false
309311
} else if (this.#byteOffset < info.payloadLength) {
312+
this.#buffers.unshift(info.header)
313+
this.#byteOffset += 2
314+
310315
callback()
311316
return false
312317
}
@@ -405,14 +410,17 @@ class ByteParser extends Writable {
405410
* Parses continuation frames.
406411
* @param {Buffer} data
407412
* @param {(err?: Error) => void} callback
408-
* @param {{ fin: boolean, fragmented: boolean, payloadLength: number }} info
413+
* @param {{ fin: boolean, fragmented: boolean, payloadLength: number, header: Buffer }} info
409414
*/
410415
parseContinuationFrame (callback, info) {
411416
// If we received a continuation frame before we started parsing another frame.
412417
if (this.#info.opcode === undefined) {
413418
failWebsocketConnection(this.ws, 'Received unexpected continuation frame.')
414419
return false
415420
} else if (this.#byteOffset < info.payloadLength) {
421+
this.#buffers.unshift(info.header)
422+
this.#byteOffset += 2
423+
416424
callback()
417425
return false
418426
}

0 commit comments

Comments
 (0)