Skip to content

Commit

Permalink
websocket: remove dead code in parseCloseBody (#2902)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Mar 2, 2024
1 parent 7a92eee commit fc4e766
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/web/websocket/receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ByteParser extends Writable {

const body = this.consume(payloadLength)

this.#info.closeInfo = this.parseCloseBody(false, body)
this.#info.closeInfo = this.parseCloseBody(body)

if (!this.ws[kSentClose]) {
// If an endpoint receives a Close frame and did not previously send a
Expand Down Expand Up @@ -290,7 +290,7 @@ class ByteParser extends Writable {
return buffer
}

parseCloseBody (onlyCode, data) {
parseCloseBody (data) {
// https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5
/** @type {number|undefined} */
let code
Expand All @@ -302,14 +302,6 @@ class ByteParser extends Writable {
code = data.readUInt16BE(0)
}

if (onlyCode) {
if (!isValidStatusCode(code)) {
return null
}

return { code }
}

// https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.6
/** @type {Buffer} */
let reason = data.subarray(2)
Expand Down

0 comments on commit fc4e766

Please sign in to comment.