mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2026-07-04 23:51:37 +00:00
build(deps): bump undici from 6.24.0 to 6.27.0
This commit is contained in:
+192
-56
@@ -34840,7 +34840,6 @@ function defaultFactory (origin, opts) {
|
|||||||
|
|
||||||
class Agent extends DispatcherBase {
|
class Agent extends DispatcherBase {
|
||||||
constructor ({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
|
constructor ({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
|
||||||
|
|
||||||
if (typeof factory !== 'function') {
|
if (typeof factory !== 'function') {
|
||||||
throw new InvalidArgumentError('factory must be a function.')
|
throw new InvalidArgumentError('factory must be a function.')
|
||||||
}
|
}
|
||||||
@@ -35228,6 +35227,9 @@ const EMPTY_BUF = Buffer.alloc(0)
|
|||||||
const FastBuffer = Buffer[Symbol.species]
|
const FastBuffer = Buffer[Symbol.species]
|
||||||
const addListener = util.addListener
|
const addListener = util.addListener
|
||||||
const removeAllListeners = util.removeAllListeners
|
const removeAllListeners = util.removeAllListeners
|
||||||
|
const kIdleSocketValidation = Symbol('kIdleSocketValidation')
|
||||||
|
const kIdleSocketValidationTimeout = Symbol('kIdleSocketValidationTimeout')
|
||||||
|
const kSocketUsed = Symbol('kSocketUsed')
|
||||||
|
|
||||||
let extractBody
|
let extractBody
|
||||||
|
|
||||||
@@ -35450,29 +35452,71 @@ class Parser {
|
|||||||
|
|
||||||
const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr
|
const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr
|
||||||
|
|
||||||
if (ret === constants.ERROR.PAUSED_UPGRADE) {
|
if (ret !== constants.ERROR.OK) {
|
||||||
this.onUpgrade(data.slice(offset))
|
const body = data.subarray(offset)
|
||||||
} else if (ret === constants.ERROR.PAUSED) {
|
|
||||||
this.paused = true
|
if (ret === constants.ERROR.PAUSED_UPGRADE) {
|
||||||
socket.unshift(data.slice(offset))
|
this.onUpgrade(body)
|
||||||
} else if (ret !== constants.ERROR.OK) {
|
} else if (ret === constants.ERROR.PAUSED) {
|
||||||
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
|
this.paused = true
|
||||||
let message = ''
|
socket.unshift(body)
|
||||||
/* istanbul ignore else: difficult to make a test case for */
|
} else {
|
||||||
if (ptr) {
|
throw this.createError(ret, body)
|
||||||
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
|
||||||
message =
|
|
||||||
'Response does not match the HTTP/1.1 protocol (' +
|
|
||||||
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
|
|
||||||
')'
|
|
||||||
}
|
}
|
||||||
throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset))
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
util.destroy(socket, err)
|
util.destroy(socket, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finish () {
|
||||||
|
assert(currentParser === null)
|
||||||
|
assert(this.ptr != null)
|
||||||
|
assert(!this.paused)
|
||||||
|
|
||||||
|
const { llhttp } = this
|
||||||
|
|
||||||
|
let ret
|
||||||
|
|
||||||
|
try {
|
||||||
|
currentParser = this
|
||||||
|
ret = llhttp.llhttp_finish(this.ptr)
|
||||||
|
} finally {
|
||||||
|
currentParser = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret === constants.ERROR.OK) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
|
||||||
|
this.paused = true
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.createError(ret, EMPTY_BUF)
|
||||||
|
}
|
||||||
|
|
||||||
|
createError (ret, data) {
|
||||||
|
const { llhttp, contentLength, bytesRead } = this
|
||||||
|
|
||||||
|
if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
|
||||||
|
return new ResponseContentLengthMismatchError()
|
||||||
|
}
|
||||||
|
|
||||||
|
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
|
||||||
|
let message = ''
|
||||||
|
if (ptr) {
|
||||||
|
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
||||||
|
message =
|
||||||
|
'Response does not match the HTTP/1.1 protocol (' +
|
||||||
|
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
|
||||||
|
')'
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HTTPParserError(message, constants.ERROR[ret], data)
|
||||||
|
}
|
||||||
|
|
||||||
destroy () {
|
destroy () {
|
||||||
assert(this.ptr != null)
|
assert(this.ptr != null)
|
||||||
assert(currentParser == null)
|
assert(currentParser == null)
|
||||||
@@ -35500,6 +35544,11 @@ class Parser {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client[kRunning] === 0) {
|
||||||
|
util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
const request = client[kQueue][client[kRunningIdx]]
|
const request = client[kQueue][client[kRunningIdx]]
|
||||||
if (!request) {
|
if (!request) {
|
||||||
return -1
|
return -1
|
||||||
@@ -35603,6 +35652,11 @@ class Parser {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client[kRunning] === 0) {
|
||||||
|
util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
const request = client[kQueue][client[kRunningIdx]]
|
const request = client[kQueue][client[kRunningIdx]]
|
||||||
|
|
||||||
/* istanbul ignore next: difficult to make a test case for */
|
/* istanbul ignore next: difficult to make a test case for */
|
||||||
@@ -35776,6 +35830,7 @@ class Parser {
|
|||||||
request.onComplete(headers)
|
request.onComplete(headers)
|
||||||
|
|
||||||
client[kQueue][client[kRunningIdx]++] = null
|
client[kQueue][client[kRunningIdx]++] = null
|
||||||
|
socket[kSocketUsed] = true
|
||||||
|
|
||||||
if (socket[kWriting]) {
|
if (socket[kWriting]) {
|
||||||
assert(client[kRunning] === 0)
|
assert(client[kRunning] === 0)
|
||||||
@@ -35834,6 +35889,9 @@ async function connectH1 (client, socket) {
|
|||||||
socket[kWriting] = false
|
socket[kWriting] = false
|
||||||
socket[kReset] = false
|
socket[kReset] = false
|
||||||
socket[kBlocking] = false
|
socket[kBlocking] = false
|
||||||
|
socket[kIdleSocketValidation] = 0
|
||||||
|
socket[kIdleSocketValidationTimeout] = null
|
||||||
|
socket[kSocketUsed] = false
|
||||||
socket[kParser] = new Parser(client, socket, llhttpInstance)
|
socket[kParser] = new Parser(client, socket, llhttpInstance)
|
||||||
|
|
||||||
addListener(socket, 'error', function (err) {
|
addListener(socket, 'error', function (err) {
|
||||||
@@ -35844,8 +35902,11 @@ async function connectH1 (client, socket) {
|
|||||||
// On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
|
// On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
|
||||||
// to the user.
|
// to the user.
|
||||||
if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
|
if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
|
||||||
// We treat all incoming data so for as a valid response.
|
const parserErr = parser.finish()
|
||||||
parser.onMessageComplete()
|
if (parserErr) {
|
||||||
|
this[kError] = parserErr
|
||||||
|
this[kClient][kOnError](parserErr)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35864,8 +35925,10 @@ async function connectH1 (client, socket) {
|
|||||||
const parser = this[kParser]
|
const parser = this[kParser]
|
||||||
|
|
||||||
if (parser.statusCode && !parser.shouldKeepAlive) {
|
if (parser.statusCode && !parser.shouldKeepAlive) {
|
||||||
// We treat all incoming data so far as a valid response.
|
const parserErr = parser.finish()
|
||||||
parser.onMessageComplete()
|
if (parserErr) {
|
||||||
|
util.destroy(this, parserErr)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35875,10 +35938,11 @@ async function connectH1 (client, socket) {
|
|||||||
const client = this[kClient]
|
const client = this[kClient]
|
||||||
const parser = this[kParser]
|
const parser = this[kParser]
|
||||||
|
|
||||||
|
clearIdleSocketValidation(this)
|
||||||
|
|
||||||
if (parser) {
|
if (parser) {
|
||||||
if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
|
if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
|
||||||
// We treat all incoming data so far as a valid response.
|
this[kError] = parser.finish() || this[kError]
|
||||||
parser.onMessageComplete()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this[kParser].destroy()
|
this[kParser].destroy()
|
||||||
@@ -35941,7 +36005,7 @@ async function connectH1 (client, socket) {
|
|||||||
return socket.destroyed
|
return socket.destroyed
|
||||||
},
|
},
|
||||||
busy (request) {
|
busy (request) {
|
||||||
if (socket[kWriting] || socket[kReset] || socket[kBlocking]) {
|
if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35979,6 +36043,31 @@ async function connectH1 (client, socket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearIdleSocketValidation (socket) {
|
||||||
|
if (socket[kIdleSocketValidationTimeout]) {
|
||||||
|
clearTimeout(socket[kIdleSocketValidationTimeout])
|
||||||
|
socket[kIdleSocketValidationTimeout] = null
|
||||||
|
}
|
||||||
|
|
||||||
|
socket[kIdleSocketValidation] = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function scheduleIdleSocketValidation (client, socket) {
|
||||||
|
socket[kIdleSocketValidation] = 1
|
||||||
|
socket[kIdleSocketValidationTimeout] = setTimeout(() => {
|
||||||
|
socket[kIdleSocketValidationTimeout] = null
|
||||||
|
socket[kIdleSocketValidation] = 2
|
||||||
|
|
||||||
|
if (client[kSocket] === socket && !socket.destroyed) {
|
||||||
|
client[kResume]()
|
||||||
|
}
|
||||||
|
}, 0)
|
||||||
|
socket[kIdleSocketValidationTimeout].unref?.()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('./client.js')} client
|
||||||
|
*/
|
||||||
function resumeH1 (client) {
|
function resumeH1 (client) {
|
||||||
const socket = client[kSocket]
|
const socket = client[kSocket]
|
||||||
|
|
||||||
@@ -35993,6 +36082,32 @@ function resumeH1 (client) {
|
|||||||
socket[kNoRef] = false
|
socket[kNoRef] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
|
||||||
|
if (socket[kIdleSocketValidation] === 0) {
|
||||||
|
scheduleIdleSocketValidation(client, socket)
|
||||||
|
socket[kParser].readMore()
|
||||||
|
if (socket.destroyed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (socket[kIdleSocketValidation] === 1) {
|
||||||
|
socket[kParser].readMore()
|
||||||
|
if (socket.destroyed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client[kRunning] === 0) {
|
||||||
|
socket[kParser].readMore()
|
||||||
|
if (socket.destroyed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (client[kSize] === 0) {
|
if (client[kSize] === 0) {
|
||||||
if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) {
|
if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) {
|
||||||
socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE)
|
socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE)
|
||||||
@@ -36086,6 +36201,7 @@ function writeH1 (client, request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const socket = client[kSocket]
|
const socket = client[kSocket]
|
||||||
|
clearIdleSocketValidation(socket)
|
||||||
|
|
||||||
const abort = (err) => {
|
const abort = (err) => {
|
||||||
if (request.aborted || request.completed) {
|
if (request.aborted || request.completed) {
|
||||||
@@ -37958,6 +38074,7 @@ class DispatcherBase extends Dispatcher {
|
|||||||
|
|
||||||
get webSocketOptions () {
|
get webSocketOptions () {
|
||||||
return {
|
return {
|
||||||
|
maxFragments: this[kWebSocketOptions].maxFragments ?? 131072,
|
||||||
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43894,32 +44011,25 @@ function parseUnparsedAttributes (unparsedAttributes, cookieAttributeList = {})
|
|||||||
// If the attribute-name case-insensitively matches the string
|
// If the attribute-name case-insensitively matches the string
|
||||||
// "SameSite", the user agent MUST process the cookie-av as follows:
|
// "SameSite", the user agent MUST process the cookie-av as follows:
|
||||||
|
|
||||||
// 1. Let enforcement be "Default".
|
|
||||||
let enforcement = 'Default'
|
|
||||||
|
|
||||||
const attributeValueLowercase = attributeValue.toLowerCase()
|
const attributeValueLowercase = attributeValue.toLowerCase()
|
||||||
// 2. If cookie-av's attribute-value is a case-insensitive match for
|
|
||||||
// "None", set enforcement to "None".
|
|
||||||
if (attributeValueLowercase.includes('none')) {
|
|
||||||
enforcement = 'None'
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. If cookie-av's attribute-value is a case-insensitive match for
|
// 1. If cookie-av's attribute-value is a case-insensitive match for
|
||||||
// "Strict", set enforcement to "Strict".
|
// "None", append an attribute to the cookie-attribute-list with an
|
||||||
if (attributeValueLowercase.includes('strict')) {
|
// attribute-name of "SameSite" and an attribute-value of "None".
|
||||||
enforcement = 'Strict'
|
if (attributeValueLowercase === 'none') {
|
||||||
|
cookieAttributeList.sameSite = 'None'
|
||||||
|
} else if (attributeValueLowercase === 'strict') {
|
||||||
|
// 2. If cookie-av's attribute-value is a case-insensitive match for
|
||||||
|
// "Strict", append an attribute to the cookie-attribute-list with
|
||||||
|
// an attribute-name of "SameSite" and an attribute-value of
|
||||||
|
// "Strict".
|
||||||
|
cookieAttributeList.sameSite = 'Strict'
|
||||||
|
} else if (attributeValueLowercase === 'lax') {
|
||||||
|
// 3. If cookie-av's attribute-value is a case-insensitive match for
|
||||||
|
// "Lax", append an attribute to the cookie-attribute-list with an
|
||||||
|
// attribute-name of "SameSite" and an attribute-value of "Lax".
|
||||||
|
cookieAttributeList.sameSite = 'Lax'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. If cookie-av's attribute-value is a case-insensitive match for
|
|
||||||
// "Lax", set enforcement to "Lax".
|
|
||||||
if (attributeValueLowercase.includes('lax')) {
|
|
||||||
enforcement = 'Lax'
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. Append an attribute to the cookie-attribute-list with an
|
|
||||||
// attribute-name of "SameSite" and an attribute-value of
|
|
||||||
// enforcement.
|
|
||||||
cookieAttributeList.sameSite = enforcement
|
|
||||||
} else {
|
} else {
|
||||||
cookieAttributeList.unparsed ??= []
|
cookieAttributeList.unparsed ??= []
|
||||||
|
|
||||||
@@ -56745,6 +56855,11 @@ const { closeWebSocketConnection } = __nccwpck_require__(86897)
|
|||||||
const { PerMessageDeflate } = __nccwpck_require__(19469)
|
const { PerMessageDeflate } = __nccwpck_require__(19469)
|
||||||
const { MessageSizeExceededError } = __nccwpck_require__(68707)
|
const { MessageSizeExceededError } = __nccwpck_require__(68707)
|
||||||
|
|
||||||
|
function failWebsocketConnectionWithCode (ws, code, reason) {
|
||||||
|
closeWebSocketConnection(ws, code, reason, Buffer.byteLength(reason))
|
||||||
|
failWebsocketConnection(ws, reason)
|
||||||
|
}
|
||||||
|
|
||||||
// This code was influenced by ws released under the MIT license.
|
// This code was influenced by ws released under the MIT license.
|
||||||
// Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
// Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
||||||
// Copyright (c) 2013 Arnout Kazemier and contributors
|
// Copyright (c) 2013 Arnout Kazemier and contributors
|
||||||
@@ -56764,19 +56879,23 @@ class ByteParser extends Writable {
|
|||||||
/** @type {Map<string, PerMessageDeflate>} */
|
/** @type {Map<string, PerMessageDeflate>} */
|
||||||
#extensions
|
#extensions
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
#maxFragments
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
#maxPayloadSize
|
#maxPayloadSize
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('./websocket').WebSocket} ws
|
* @param {import('./websocket').WebSocket} ws
|
||||||
* @param {Map<string, string>|null} extensions
|
* @param {Map<string, string>|null} extensions
|
||||||
* @param {{ maxPayloadSize?: number }} [options]
|
* @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
|
||||||
*/
|
*/
|
||||||
constructor (ws, extensions, options = {}) {
|
constructor (ws, extensions, options = {}) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.ws = ws
|
this.ws = ws
|
||||||
this.#extensions = extensions == null ? new Map() : extensions
|
this.#extensions = extensions == null ? new Map() : extensions
|
||||||
|
this.#maxFragments = options.maxFragments ?? 0
|
||||||
this.#maxPayloadSize = options.maxPayloadSize ?? 0
|
this.#maxPayloadSize = options.maxPayloadSize ?? 0
|
||||||
|
|
||||||
if (this.#extensions.has('permessage-deflate')) {
|
if (this.#extensions.has('permessage-deflate')) {
|
||||||
@@ -56800,9 +56919,9 @@ class ByteParser extends Writable {
|
|||||||
if (
|
if (
|
||||||
this.#maxPayloadSize > 0 &&
|
this.#maxPayloadSize > 0 &&
|
||||||
!isControlFrame(this.#info.opcode) &&
|
!isControlFrame(this.#info.opcode) &&
|
||||||
this.#info.payloadLength > this.#maxPayloadSize
|
this.#info.payloadLength + this.#fragmentsBytes > this.#maxPayloadSize
|
||||||
) {
|
) {
|
||||||
failWebsocketConnection(this.ws, 'Payload size exceeds maximum allowed size')
|
failWebsocketConnectionWithCode(this.ws, 1009, 'Payload size exceeds maximum allowed size')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56967,10 +57086,12 @@ class ByteParser extends Writable {
|
|||||||
this.#state = parserStates.INFO
|
this.#state = parserStates.INFO
|
||||||
} else {
|
} else {
|
||||||
if (!this.#info.compressed) {
|
if (!this.#info.compressed) {
|
||||||
this.writeFragments(body)
|
if (!this.writeFragments(body)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
||||||
failWebsocketConnection(this.ws, new MessageSizeExceededError().message)
|
failWebsocketConnectionWithCode(this.ws, 1009, new MessageSizeExceededError().message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56989,14 +57110,17 @@ class ByteParser extends Writable {
|
|||||||
this.#info.fin,
|
this.#info.fin,
|
||||||
(error, data) => {
|
(error, data) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
failWebsocketConnection(this.ws, error.message)
|
const code = error instanceof MessageSizeExceededError ? 1009 : 1007
|
||||||
|
failWebsocketConnectionWithCode(this.ws, code, error.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.writeFragments(data)
|
if (!this.writeFragments(data)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
||||||
failWebsocketConnection(this.ws, new MessageSizeExceededError().message)
|
failWebsocketConnectionWithCode(this.ws, 1009, new MessageSizeExceededError().message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57066,8 +57190,17 @@ class ByteParser extends Writable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeFragments (fragment) {
|
writeFragments (fragment) {
|
||||||
|
if (
|
||||||
|
this.#maxFragments > 0 &&
|
||||||
|
this.#fragments.length === this.#maxFragments
|
||||||
|
) {
|
||||||
|
failWebsocketConnectionWithCode(this.ws, 1008, 'Too many message fragments')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
this.#fragmentsBytes += fragment.length
|
this.#fragmentsBytes += fragment.length
|
||||||
this.#fragments.push(fragment)
|
this.#fragments.push(fragment)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
consumeFragments () {
|
consumeFragments () {
|
||||||
@@ -58120,9 +58253,12 @@ class WebSocket extends EventTarget {
|
|||||||
// once this happens, the connection is open
|
// once this happens, the connection is open
|
||||||
this[kResponse] = response
|
this[kResponse] = response
|
||||||
|
|
||||||
const maxPayloadSize = this[kController]?.dispatcher?.webSocketOptions?.maxPayloadSize
|
const webSocketOptions = this[kController]?.dispatcher?.webSocketOptions
|
||||||
|
const maxFragments = webSocketOptions?.maxFragments
|
||||||
|
const maxPayloadSize = webSocketOptions?.maxPayloadSize
|
||||||
|
|
||||||
const parser = new ByteParser(this, parsedExtensions, {
|
const parser = new ByteParser(this, parsedExtensions, {
|
||||||
|
maxFragments,
|
||||||
maxPayloadSize
|
maxPayloadSize
|
||||||
})
|
})
|
||||||
parser.on('drain', onParserDrain)
|
parser.on('drain', onParserDrain)
|
||||||
|
|||||||
+192
-56
@@ -34840,7 +34840,6 @@ function defaultFactory (origin, opts) {
|
|||||||
|
|
||||||
class Agent extends DispatcherBase {
|
class Agent extends DispatcherBase {
|
||||||
constructor ({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
|
constructor ({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
|
||||||
|
|
||||||
if (typeof factory !== 'function') {
|
if (typeof factory !== 'function') {
|
||||||
throw new InvalidArgumentError('factory must be a function.')
|
throw new InvalidArgumentError('factory must be a function.')
|
||||||
}
|
}
|
||||||
@@ -35228,6 +35227,9 @@ const EMPTY_BUF = Buffer.alloc(0)
|
|||||||
const FastBuffer = Buffer[Symbol.species]
|
const FastBuffer = Buffer[Symbol.species]
|
||||||
const addListener = util.addListener
|
const addListener = util.addListener
|
||||||
const removeAllListeners = util.removeAllListeners
|
const removeAllListeners = util.removeAllListeners
|
||||||
|
const kIdleSocketValidation = Symbol('kIdleSocketValidation')
|
||||||
|
const kIdleSocketValidationTimeout = Symbol('kIdleSocketValidationTimeout')
|
||||||
|
const kSocketUsed = Symbol('kSocketUsed')
|
||||||
|
|
||||||
let extractBody
|
let extractBody
|
||||||
|
|
||||||
@@ -35450,29 +35452,71 @@ class Parser {
|
|||||||
|
|
||||||
const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr
|
const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr
|
||||||
|
|
||||||
if (ret === constants.ERROR.PAUSED_UPGRADE) {
|
if (ret !== constants.ERROR.OK) {
|
||||||
this.onUpgrade(data.slice(offset))
|
const body = data.subarray(offset)
|
||||||
} else if (ret === constants.ERROR.PAUSED) {
|
|
||||||
this.paused = true
|
if (ret === constants.ERROR.PAUSED_UPGRADE) {
|
||||||
socket.unshift(data.slice(offset))
|
this.onUpgrade(body)
|
||||||
} else if (ret !== constants.ERROR.OK) {
|
} else if (ret === constants.ERROR.PAUSED) {
|
||||||
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
|
this.paused = true
|
||||||
let message = ''
|
socket.unshift(body)
|
||||||
/* istanbul ignore else: difficult to make a test case for */
|
} else {
|
||||||
if (ptr) {
|
throw this.createError(ret, body)
|
||||||
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
|
||||||
message =
|
|
||||||
'Response does not match the HTTP/1.1 protocol (' +
|
|
||||||
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
|
|
||||||
')'
|
|
||||||
}
|
}
|
||||||
throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset))
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
util.destroy(socket, err)
|
util.destroy(socket, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finish () {
|
||||||
|
assert(currentParser === null)
|
||||||
|
assert(this.ptr != null)
|
||||||
|
assert(!this.paused)
|
||||||
|
|
||||||
|
const { llhttp } = this
|
||||||
|
|
||||||
|
let ret
|
||||||
|
|
||||||
|
try {
|
||||||
|
currentParser = this
|
||||||
|
ret = llhttp.llhttp_finish(this.ptr)
|
||||||
|
} finally {
|
||||||
|
currentParser = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret === constants.ERROR.OK) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
|
||||||
|
this.paused = true
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.createError(ret, EMPTY_BUF)
|
||||||
|
}
|
||||||
|
|
||||||
|
createError (ret, data) {
|
||||||
|
const { llhttp, contentLength, bytesRead } = this
|
||||||
|
|
||||||
|
if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
|
||||||
|
return new ResponseContentLengthMismatchError()
|
||||||
|
}
|
||||||
|
|
||||||
|
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
|
||||||
|
let message = ''
|
||||||
|
if (ptr) {
|
||||||
|
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
||||||
|
message =
|
||||||
|
'Response does not match the HTTP/1.1 protocol (' +
|
||||||
|
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
|
||||||
|
')'
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HTTPParserError(message, constants.ERROR[ret], data)
|
||||||
|
}
|
||||||
|
|
||||||
destroy () {
|
destroy () {
|
||||||
assert(this.ptr != null)
|
assert(this.ptr != null)
|
||||||
assert(currentParser == null)
|
assert(currentParser == null)
|
||||||
@@ -35500,6 +35544,11 @@ class Parser {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client[kRunning] === 0) {
|
||||||
|
util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
const request = client[kQueue][client[kRunningIdx]]
|
const request = client[kQueue][client[kRunningIdx]]
|
||||||
if (!request) {
|
if (!request) {
|
||||||
return -1
|
return -1
|
||||||
@@ -35603,6 +35652,11 @@ class Parser {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client[kRunning] === 0) {
|
||||||
|
util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
const request = client[kQueue][client[kRunningIdx]]
|
const request = client[kQueue][client[kRunningIdx]]
|
||||||
|
|
||||||
/* istanbul ignore next: difficult to make a test case for */
|
/* istanbul ignore next: difficult to make a test case for */
|
||||||
@@ -35776,6 +35830,7 @@ class Parser {
|
|||||||
request.onComplete(headers)
|
request.onComplete(headers)
|
||||||
|
|
||||||
client[kQueue][client[kRunningIdx]++] = null
|
client[kQueue][client[kRunningIdx]++] = null
|
||||||
|
socket[kSocketUsed] = true
|
||||||
|
|
||||||
if (socket[kWriting]) {
|
if (socket[kWriting]) {
|
||||||
assert(client[kRunning] === 0)
|
assert(client[kRunning] === 0)
|
||||||
@@ -35834,6 +35889,9 @@ async function connectH1 (client, socket) {
|
|||||||
socket[kWriting] = false
|
socket[kWriting] = false
|
||||||
socket[kReset] = false
|
socket[kReset] = false
|
||||||
socket[kBlocking] = false
|
socket[kBlocking] = false
|
||||||
|
socket[kIdleSocketValidation] = 0
|
||||||
|
socket[kIdleSocketValidationTimeout] = null
|
||||||
|
socket[kSocketUsed] = false
|
||||||
socket[kParser] = new Parser(client, socket, llhttpInstance)
|
socket[kParser] = new Parser(client, socket, llhttpInstance)
|
||||||
|
|
||||||
addListener(socket, 'error', function (err) {
|
addListener(socket, 'error', function (err) {
|
||||||
@@ -35844,8 +35902,11 @@ async function connectH1 (client, socket) {
|
|||||||
// On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
|
// On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
|
||||||
// to the user.
|
// to the user.
|
||||||
if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
|
if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
|
||||||
// We treat all incoming data so for as a valid response.
|
const parserErr = parser.finish()
|
||||||
parser.onMessageComplete()
|
if (parserErr) {
|
||||||
|
this[kError] = parserErr
|
||||||
|
this[kClient][kOnError](parserErr)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35864,8 +35925,10 @@ async function connectH1 (client, socket) {
|
|||||||
const parser = this[kParser]
|
const parser = this[kParser]
|
||||||
|
|
||||||
if (parser.statusCode && !parser.shouldKeepAlive) {
|
if (parser.statusCode && !parser.shouldKeepAlive) {
|
||||||
// We treat all incoming data so far as a valid response.
|
const parserErr = parser.finish()
|
||||||
parser.onMessageComplete()
|
if (parserErr) {
|
||||||
|
util.destroy(this, parserErr)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35875,10 +35938,11 @@ async function connectH1 (client, socket) {
|
|||||||
const client = this[kClient]
|
const client = this[kClient]
|
||||||
const parser = this[kParser]
|
const parser = this[kParser]
|
||||||
|
|
||||||
|
clearIdleSocketValidation(this)
|
||||||
|
|
||||||
if (parser) {
|
if (parser) {
|
||||||
if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
|
if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
|
||||||
// We treat all incoming data so far as a valid response.
|
this[kError] = parser.finish() || this[kError]
|
||||||
parser.onMessageComplete()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this[kParser].destroy()
|
this[kParser].destroy()
|
||||||
@@ -35941,7 +36005,7 @@ async function connectH1 (client, socket) {
|
|||||||
return socket.destroyed
|
return socket.destroyed
|
||||||
},
|
},
|
||||||
busy (request) {
|
busy (request) {
|
||||||
if (socket[kWriting] || socket[kReset] || socket[kBlocking]) {
|
if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35979,6 +36043,31 @@ async function connectH1 (client, socket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearIdleSocketValidation (socket) {
|
||||||
|
if (socket[kIdleSocketValidationTimeout]) {
|
||||||
|
clearTimeout(socket[kIdleSocketValidationTimeout])
|
||||||
|
socket[kIdleSocketValidationTimeout] = null
|
||||||
|
}
|
||||||
|
|
||||||
|
socket[kIdleSocketValidation] = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function scheduleIdleSocketValidation (client, socket) {
|
||||||
|
socket[kIdleSocketValidation] = 1
|
||||||
|
socket[kIdleSocketValidationTimeout] = setTimeout(() => {
|
||||||
|
socket[kIdleSocketValidationTimeout] = null
|
||||||
|
socket[kIdleSocketValidation] = 2
|
||||||
|
|
||||||
|
if (client[kSocket] === socket && !socket.destroyed) {
|
||||||
|
client[kResume]()
|
||||||
|
}
|
||||||
|
}, 0)
|
||||||
|
socket[kIdleSocketValidationTimeout].unref?.()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('./client.js')} client
|
||||||
|
*/
|
||||||
function resumeH1 (client) {
|
function resumeH1 (client) {
|
||||||
const socket = client[kSocket]
|
const socket = client[kSocket]
|
||||||
|
|
||||||
@@ -35993,6 +36082,32 @@ function resumeH1 (client) {
|
|||||||
socket[kNoRef] = false
|
socket[kNoRef] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
|
||||||
|
if (socket[kIdleSocketValidation] === 0) {
|
||||||
|
scheduleIdleSocketValidation(client, socket)
|
||||||
|
socket[kParser].readMore()
|
||||||
|
if (socket.destroyed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (socket[kIdleSocketValidation] === 1) {
|
||||||
|
socket[kParser].readMore()
|
||||||
|
if (socket.destroyed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client[kRunning] === 0) {
|
||||||
|
socket[kParser].readMore()
|
||||||
|
if (socket.destroyed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (client[kSize] === 0) {
|
if (client[kSize] === 0) {
|
||||||
if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) {
|
if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) {
|
||||||
socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE)
|
socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE)
|
||||||
@@ -36086,6 +36201,7 @@ function writeH1 (client, request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const socket = client[kSocket]
|
const socket = client[kSocket]
|
||||||
|
clearIdleSocketValidation(socket)
|
||||||
|
|
||||||
const abort = (err) => {
|
const abort = (err) => {
|
||||||
if (request.aborted || request.completed) {
|
if (request.aborted || request.completed) {
|
||||||
@@ -37958,6 +38074,7 @@ class DispatcherBase extends Dispatcher {
|
|||||||
|
|
||||||
get webSocketOptions () {
|
get webSocketOptions () {
|
||||||
return {
|
return {
|
||||||
|
maxFragments: this[kWebSocketOptions].maxFragments ?? 131072,
|
||||||
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43894,32 +44011,25 @@ function parseUnparsedAttributes (unparsedAttributes, cookieAttributeList = {})
|
|||||||
// If the attribute-name case-insensitively matches the string
|
// If the attribute-name case-insensitively matches the string
|
||||||
// "SameSite", the user agent MUST process the cookie-av as follows:
|
// "SameSite", the user agent MUST process the cookie-av as follows:
|
||||||
|
|
||||||
// 1. Let enforcement be "Default".
|
|
||||||
let enforcement = 'Default'
|
|
||||||
|
|
||||||
const attributeValueLowercase = attributeValue.toLowerCase()
|
const attributeValueLowercase = attributeValue.toLowerCase()
|
||||||
// 2. If cookie-av's attribute-value is a case-insensitive match for
|
|
||||||
// "None", set enforcement to "None".
|
|
||||||
if (attributeValueLowercase.includes('none')) {
|
|
||||||
enforcement = 'None'
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. If cookie-av's attribute-value is a case-insensitive match for
|
// 1. If cookie-av's attribute-value is a case-insensitive match for
|
||||||
// "Strict", set enforcement to "Strict".
|
// "None", append an attribute to the cookie-attribute-list with an
|
||||||
if (attributeValueLowercase.includes('strict')) {
|
// attribute-name of "SameSite" and an attribute-value of "None".
|
||||||
enforcement = 'Strict'
|
if (attributeValueLowercase === 'none') {
|
||||||
|
cookieAttributeList.sameSite = 'None'
|
||||||
|
} else if (attributeValueLowercase === 'strict') {
|
||||||
|
// 2. If cookie-av's attribute-value is a case-insensitive match for
|
||||||
|
// "Strict", append an attribute to the cookie-attribute-list with
|
||||||
|
// an attribute-name of "SameSite" and an attribute-value of
|
||||||
|
// "Strict".
|
||||||
|
cookieAttributeList.sameSite = 'Strict'
|
||||||
|
} else if (attributeValueLowercase === 'lax') {
|
||||||
|
// 3. If cookie-av's attribute-value is a case-insensitive match for
|
||||||
|
// "Lax", append an attribute to the cookie-attribute-list with an
|
||||||
|
// attribute-name of "SameSite" and an attribute-value of "Lax".
|
||||||
|
cookieAttributeList.sameSite = 'Lax'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. If cookie-av's attribute-value is a case-insensitive match for
|
|
||||||
// "Lax", set enforcement to "Lax".
|
|
||||||
if (attributeValueLowercase.includes('lax')) {
|
|
||||||
enforcement = 'Lax'
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. Append an attribute to the cookie-attribute-list with an
|
|
||||||
// attribute-name of "SameSite" and an attribute-value of
|
|
||||||
// enforcement.
|
|
||||||
cookieAttributeList.sameSite = enforcement
|
|
||||||
} else {
|
} else {
|
||||||
cookieAttributeList.unparsed ??= []
|
cookieAttributeList.unparsed ??= []
|
||||||
|
|
||||||
@@ -56745,6 +56855,11 @@ const { closeWebSocketConnection } = __nccwpck_require__(86897)
|
|||||||
const { PerMessageDeflate } = __nccwpck_require__(19469)
|
const { PerMessageDeflate } = __nccwpck_require__(19469)
|
||||||
const { MessageSizeExceededError } = __nccwpck_require__(68707)
|
const { MessageSizeExceededError } = __nccwpck_require__(68707)
|
||||||
|
|
||||||
|
function failWebsocketConnectionWithCode (ws, code, reason) {
|
||||||
|
closeWebSocketConnection(ws, code, reason, Buffer.byteLength(reason))
|
||||||
|
failWebsocketConnection(ws, reason)
|
||||||
|
}
|
||||||
|
|
||||||
// This code was influenced by ws released under the MIT license.
|
// This code was influenced by ws released under the MIT license.
|
||||||
// Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
// Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
||||||
// Copyright (c) 2013 Arnout Kazemier and contributors
|
// Copyright (c) 2013 Arnout Kazemier and contributors
|
||||||
@@ -56764,19 +56879,23 @@ class ByteParser extends Writable {
|
|||||||
/** @type {Map<string, PerMessageDeflate>} */
|
/** @type {Map<string, PerMessageDeflate>} */
|
||||||
#extensions
|
#extensions
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
#maxFragments
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
#maxPayloadSize
|
#maxPayloadSize
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('./websocket').WebSocket} ws
|
* @param {import('./websocket').WebSocket} ws
|
||||||
* @param {Map<string, string>|null} extensions
|
* @param {Map<string, string>|null} extensions
|
||||||
* @param {{ maxPayloadSize?: number }} [options]
|
* @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
|
||||||
*/
|
*/
|
||||||
constructor (ws, extensions, options = {}) {
|
constructor (ws, extensions, options = {}) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.ws = ws
|
this.ws = ws
|
||||||
this.#extensions = extensions == null ? new Map() : extensions
|
this.#extensions = extensions == null ? new Map() : extensions
|
||||||
|
this.#maxFragments = options.maxFragments ?? 0
|
||||||
this.#maxPayloadSize = options.maxPayloadSize ?? 0
|
this.#maxPayloadSize = options.maxPayloadSize ?? 0
|
||||||
|
|
||||||
if (this.#extensions.has('permessage-deflate')) {
|
if (this.#extensions.has('permessage-deflate')) {
|
||||||
@@ -56800,9 +56919,9 @@ class ByteParser extends Writable {
|
|||||||
if (
|
if (
|
||||||
this.#maxPayloadSize > 0 &&
|
this.#maxPayloadSize > 0 &&
|
||||||
!isControlFrame(this.#info.opcode) &&
|
!isControlFrame(this.#info.opcode) &&
|
||||||
this.#info.payloadLength > this.#maxPayloadSize
|
this.#info.payloadLength + this.#fragmentsBytes > this.#maxPayloadSize
|
||||||
) {
|
) {
|
||||||
failWebsocketConnection(this.ws, 'Payload size exceeds maximum allowed size')
|
failWebsocketConnectionWithCode(this.ws, 1009, 'Payload size exceeds maximum allowed size')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56967,10 +57086,12 @@ class ByteParser extends Writable {
|
|||||||
this.#state = parserStates.INFO
|
this.#state = parserStates.INFO
|
||||||
} else {
|
} else {
|
||||||
if (!this.#info.compressed) {
|
if (!this.#info.compressed) {
|
||||||
this.writeFragments(body)
|
if (!this.writeFragments(body)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
||||||
failWebsocketConnection(this.ws, new MessageSizeExceededError().message)
|
failWebsocketConnectionWithCode(this.ws, 1009, new MessageSizeExceededError().message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56989,14 +57110,17 @@ class ByteParser extends Writable {
|
|||||||
this.#info.fin,
|
this.#info.fin,
|
||||||
(error, data) => {
|
(error, data) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
failWebsocketConnection(this.ws, error.message)
|
const code = error instanceof MessageSizeExceededError ? 1009 : 1007
|
||||||
|
failWebsocketConnectionWithCode(this.ws, code, error.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.writeFragments(data)
|
if (!this.writeFragments(data)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
||||||
failWebsocketConnection(this.ws, new MessageSizeExceededError().message)
|
failWebsocketConnectionWithCode(this.ws, 1009, new MessageSizeExceededError().message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57066,8 +57190,17 @@ class ByteParser extends Writable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeFragments (fragment) {
|
writeFragments (fragment) {
|
||||||
|
if (
|
||||||
|
this.#maxFragments > 0 &&
|
||||||
|
this.#fragments.length === this.#maxFragments
|
||||||
|
) {
|
||||||
|
failWebsocketConnectionWithCode(this.ws, 1008, 'Too many message fragments')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
this.#fragmentsBytes += fragment.length
|
this.#fragmentsBytes += fragment.length
|
||||||
this.#fragments.push(fragment)
|
this.#fragments.push(fragment)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
consumeFragments () {
|
consumeFragments () {
|
||||||
@@ -58120,9 +58253,12 @@ class WebSocket extends EventTarget {
|
|||||||
// once this happens, the connection is open
|
// once this happens, the connection is open
|
||||||
this[kResponse] = response
|
this[kResponse] = response
|
||||||
|
|
||||||
const maxPayloadSize = this[kController]?.dispatcher?.webSocketOptions?.maxPayloadSize
|
const webSocketOptions = this[kController]?.dispatcher?.webSocketOptions
|
||||||
|
const maxFragments = webSocketOptions?.maxFragments
|
||||||
|
const maxPayloadSize = webSocketOptions?.maxPayloadSize
|
||||||
|
|
||||||
const parser = new ByteParser(this, parsedExtensions, {
|
const parser = new ByteParser(this, parsedExtensions, {
|
||||||
|
maxFragments,
|
||||||
maxPayloadSize
|
maxPayloadSize
|
||||||
})
|
})
|
||||||
parser.on('drain', onParserDrain)
|
parser.on('drain', onParserDrain)
|
||||||
|
|||||||
Generated
+3
-3
@@ -4219,9 +4219,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "6.25.0",
|
"version": "6.27.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.25.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-6.27.0.tgz",
|
||||||
"integrity": "sha512-ZgpWDC5gmNiuY9CnLVXEH8rl50xhRCuLNA97fAUnKi8RRuV4E6KG31pDTsLVUKnohJE0I3XDrTeEydAXRw47xg==",
|
"integrity": "sha512-YmfV3YnEDzXRC5lZ2jWtWWHKGUm1zIt8AhesR1tens+HTNv+YZlN/dp6G727LOvMJ8xjP9Be7Y2Sdr96LDm+pg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.17"
|
"node": ">=18.17"
|
||||||
|
|||||||
+1
-1
@@ -59,6 +59,6 @@
|
|||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"undici": "^6.24.0"
|
"undici": "^6.27.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user