mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
deps: update undici to 6.13.0
PR-URL: https://github.com/nodejs/node/pull/52493 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
1 parent
e7d0d804b2
commit
c96f1043d4
30 files changed
+855
-2310
No files matched your search
Vendored
+12
@@ -248,6 +248,18 @@ const data = {
|
||||
await fetch('https://example.com', { body: data, method: 'POST', duplex: 'half' })
|
||||
```
|
||||
|
||||
[FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) besides text data and buffers can also utilize streams via [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects:
|
||||
|
||||
```js
|
||||
import { openAsBlob } from 'node:fs'
|
||||
|
||||
const file = await openAsBlob('./big.csv')
|
||||
const body = new FormData()
|
||||
body.set('file', file, 'big.csv')
|
||||
|
||||
await fetch('http://example.com', { method: 'POST', body })
|
||||
```
|
||||
|
||||
#### `request.duplex`
|
||||
|
||||
- half
|
||||
|
||||
+6
@@ -969,6 +969,12 @@ Parameters:
|
||||
* **targets** `Array<Dispatcher>`
|
||||
* **error** `Error`
|
||||
|
||||
Emitted when the dispatcher has been disconnected from the origin.
|
||||
|
||||
> **Note**: For HTTP/2, this event is also emitted when the dispatcher has received the [GOAWAY Frame](https://webconcepts.info/concepts/http2-frame-type/0x7) with an Error with the message `HTTP/2: "GOAWAY" frame received` and the code `UND_ERR_INFO`.
|
||||
> Due to nature of the protocol of using binary frames, it is possible that requests gets hanging as a frame can be received between the `HEADER` and `DATA` frames.
|
||||
> It is recommended to handle this event and close the dispatcher to create a new HTTP/2 session.
|
||||
|
||||
### Event: `'connectionError'`
|
||||
|
||||
Parameters:
|
||||
|
||||
+4
-1
@@ -8,11 +8,14 @@ function abort (self) {
|
||||
if (self.abort) {
|
||||
self.abort(self[kSignal]?.reason)
|
||||
} else {
|
||||
self.onError(self[kSignal]?.reason ?? new RequestAbortedError())
|
||||
self.reason = self[kSignal]?.reason ?? new RequestAbortedError()
|
||||
}
|
||||
removeSignal(self)
|
||||
}
|
||||
|
||||
function addSignal (self, signal) {
|
||||
self.reason = null
|
||||
|
||||
self[kSignal] = null
|
||||
self[kListener] = null
|
||||
|
||||
|
||||
+7
-3
@@ -1,7 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('node:assert')
|
||||
const { AsyncResource } = require('node:async_hooks')
|
||||
const { InvalidArgumentError, RequestAbortedError, SocketError } = require('../core/errors')
|
||||
const { InvalidArgumentError, SocketError } = require('../core/errors')
|
||||
const util = require('../core/util')
|
||||
const { addSignal, removeSignal } = require('./abort-signal')
|
||||
|
||||
@@ -32,10 +33,13 @@ class ConnectHandler extends AsyncResource {
|
||||
}
|
||||
|
||||
onConnect (abort, context) {
|
||||
if (!this.callback) {
|
||||
throw new RequestAbortedError()
|
||||
if (this.reason) {
|
||||
abort(this.reason)
|
||||
return
|
||||
}
|
||||
|
||||
assert(this.callback)
|
||||
|
||||
this.abort = abort
|
||||
this.context = context
|
||||
}
|
||||
|
||||
+6
-4
@@ -147,12 +147,14 @@ class PipelineHandler extends AsyncResource {
|
||||
onConnect (abort, context) {
|
||||
const { ret, res } = this
|
||||
|
||||
assert(!res, 'pipeline cannot be retried')
|
||||
|
||||
if (ret.destroyed) {
|
||||
throw new RequestAbortedError()
|
||||
if (this.reason) {
|
||||
abort(this.reason)
|
||||
return
|
||||
}
|
||||
|
||||
assert(!res, 'pipeline cannot be retried')
|
||||
assert(!ret.destroyed)
|
||||
|
||||
this.abort = abort
|
||||
this.context = context
|
||||
}
|
||||
|
||||
+7
-6
@@ -1,10 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('node:assert')
|
||||
const { Readable } = require('./readable')
|
||||
const {
|
||||
InvalidArgumentError,
|
||||
RequestAbortedError
|
||||
} = require('../core/errors')
|
||||
const { InvalidArgumentError } = require('../core/errors')
|
||||
const util = require('../core/util')
|
||||
const { getResolveErrorBodyCallback } = require('./util')
|
||||
const { AsyncResource } = require('node:async_hooks')
|
||||
@@ -69,10 +67,13 @@ class RequestHandler extends AsyncResource {
|
||||
}
|
||||
|
||||
onConnect (abort, context) {
|
||||
if (!this.callback) {
|
||||
throw new RequestAbortedError()
|
||||
if (this.reason) {
|
||||
abort(this.reason)
|
||||
return
|
||||
}
|
||||
|
||||
assert(this.callback)
|
||||
|
||||
this.abort = abort
|
||||
this.context = context
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,11 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('node:assert')
|
||||
const { finished, PassThrough } = require('node:stream')
|
||||
const {
|
||||
InvalidArgumentError,
|
||||
InvalidReturnValueError,
|
||||
RequestAbortedError
|
||||
} = require('../core/errors')
|
||||
const { InvalidArgumentError, InvalidReturnValueError } = require('../core/errors')
|
||||
const util = require('../core/util')
|
||||
const { getResolveErrorBodyCallback } = require('./util')
|
||||
const { AsyncResource } = require('node:async_hooks')
|
||||
@@ -70,10 +67,13 @@ class StreamHandler extends AsyncResource {
|
||||
}
|
||||
|
||||
onConnect (abort, context) {
|
||||
if (!this.callback) {
|
||||
throw new RequestAbortedError()
|
||||
if (this.reason) {
|
||||
abort(this.reason)
|
||||
return
|
||||
}
|
||||
|
||||
assert(this.callback)
|
||||
|
||||
this.abort = abort
|
||||
this.context = context
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const { InvalidArgumentError, RequestAbortedError, SocketError } = require('../core/errors')
|
||||
const { InvalidArgumentError, SocketError } = require('../core/errors')
|
||||
const { AsyncResource } = require('node:async_hooks')
|
||||
const util = require('../core/util')
|
||||
const { addSignal, removeSignal } = require('./abort-signal')
|
||||
@@ -34,10 +34,13 @@ class UpgradeHandler extends AsyncResource {
|
||||
}
|
||||
|
||||
onConnect (abort, context) {
|
||||
if (!this.callback) {
|
||||
throw new RequestAbortedError()
|
||||
if (this.reason) {
|
||||
abort(this.reason)
|
||||
return
|
||||
}
|
||||
|
||||
assert(this.callback)
|
||||
|
||||
this.abort = abort
|
||||
this.context = null
|
||||
}
|
||||
|
||||
Vendored
+1
-3
@@ -63,9 +63,7 @@ class BodyReadable extends Readable {
|
||||
// tick as it is created, then a user who is waiting for a
|
||||
// promise (i.e micro tick) for installing a 'error' listener will
|
||||
// never get a chance and will always encounter an unhandled exception.
|
||||
// - tick => process.nextTick(fn)
|
||||
// - micro tick => queueMicrotask(fn)
|
||||
queueMicrotask(() => {
|
||||
setImmediate(() => {
|
||||
callback(err)
|
||||
})
|
||||
}
|
||||
|
||||
Vendored
+41
-8
@@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('node:assert')
|
||||
const { kDestroyed, kBodyUsed } = require('./symbols')
|
||||
const { kDestroyed, kBodyUsed, kListeners } = require('./symbols')
|
||||
const { IncomingMessage } = require('node:http')
|
||||
const stream = require('node:stream')
|
||||
const net = require('node:net')
|
||||
@@ -22,13 +22,20 @@ function isStream (obj) {
|
||||
|
||||
// based on https://github.com/node-fetch/fetch-blob/blob/8ab587d34080de94140b54f07168451e7d0b655e/index.js#L229-L241 (MIT License)
|
||||
function isBlobLike (object) {
|
||||
return (Blob && object instanceof Blob) || (
|
||||
object &&
|
||||
typeof object === 'object' &&
|
||||
(typeof object.stream === 'function' ||
|
||||
typeof object.arrayBuffer === 'function') &&
|
||||
/^(Blob|File)$/.test(object[Symbol.toStringTag])
|
||||
)
|
||||
if (object === null) {
|
||||
return false
|
||||
} else if (object instanceof Blob) {
|
||||
return true
|
||||
} else if (typeof object !== 'object') {
|
||||
return false
|
||||
} else {
|
||||
const sTag = object[Symbol.toStringTag]
|
||||
|
||||
return (sTag === 'Blob' || sTag === 'File') && (
|
||||
('stream' in object && typeof object.stream === 'function') ||
|
||||
('arrayBuffer' in object && typeof object.arrayBuffer === 'function')
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function buildURL (url, queryParams) {
|
||||
@@ -534,6 +541,29 @@ function parseRangeHeader (range) {
|
||||
: null
|
||||
}
|
||||
|
||||
function addListener (obj, name, listener) {
|
||||
const listeners = (obj[kListeners] ??= [])
|
||||
listeners.push([name, listener])
|
||||
obj.on(name, listener)
|
||||
return obj
|
||||
}
|
||||
|
||||
function removeAllListeners (obj) {
|
||||
for (const [name, listener] of obj[kListeners] ?? []) {
|
||||
obj.removeListener(name, listener)
|
||||
}
|
||||
obj[kListeners] = null
|
||||
}
|
||||
|
||||
function errorRequest (client, request, err) {
|
||||
try {
|
||||
request.onError(err)
|
||||
assert(request.aborted)
|
||||
} catch (err) {
|
||||
client.emit('error', err)
|
||||
}
|
||||
}
|
||||
|
||||
const kEnumerableProperty = Object.create(null)
|
||||
kEnumerableProperty.enumerable = true
|
||||
|
||||
@@ -556,6 +586,9 @@ module.exports = {
|
||||
isDestroyed,
|
||||
headerNameToString,
|
||||
bufferToLowerCasedHeaderName,
|
||||
addListener,
|
||||
removeAllListeners,
|
||||
errorRequest,
|
||||
parseRawHeaders,
|
||||
parseHeaders,
|
||||
parseKeepAliveTimeout,
|
||||
|
||||
+64
-69
@@ -47,7 +47,6 @@ const {
|
||||
kMaxRequests,
|
||||
kCounter,
|
||||
kMaxResponseSize,
|
||||
kListeners,
|
||||
kOnError,
|
||||
kResume,
|
||||
kHTTPContext
|
||||
@@ -56,23 +55,11 @@ const {
|
||||
const constants = require('../llhttp/constants.js')
|
||||
const EMPTY_BUF = Buffer.alloc(0)
|
||||
const FastBuffer = Buffer[Symbol.species]
|
||||
const addListener = util.addListener
|
||||
const removeAllListeners = util.removeAllListeners
|
||||
|
||||
let extractBody
|
||||
|
||||
function addListener (obj, name, listener) {
|
||||
const listeners = (obj[kListeners] ??= [])
|
||||
listeners.push([name, listener])
|
||||
obj.on(name, listener)
|
||||
return obj
|
||||
}
|
||||
|
||||
function removeAllListeners (obj) {
|
||||
for (const [name, listener] of obj[kListeners] ?? []) {
|
||||
obj.removeListener(name, listener)
|
||||
}
|
||||
obj[kListeners] = null
|
||||
}
|
||||
|
||||
async function lazyllhttp () {
|
||||
const llhttpWasmData = process.env.JEST_WORKER_ID ? require('../llhttp/llhttp-wasm.js') : undefined
|
||||
|
||||
@@ -719,14 +706,14 @@ async function connectH1 (client, socket) {
|
||||
const requests = client[kQueue].splice(client[kRunningIdx])
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i]
|
||||
errorRequest(client, request, err)
|
||||
util.errorRequest(client, request, err)
|
||||
}
|
||||
} else if (client[kRunning] > 0 && err.code !== 'UND_ERR_INFO') {
|
||||
// Fail head of pipeline.
|
||||
const request = client[kQueue][client[kRunningIdx]]
|
||||
client[kQueue][client[kRunningIdx]++] = null
|
||||
|
||||
errorRequest(client, request, err)
|
||||
util.errorRequest(client, request, err)
|
||||
}
|
||||
|
||||
client[kPendingIdx] = client[kRunningIdx]
|
||||
@@ -831,15 +818,6 @@ function resumeH1 (client) {
|
||||
}
|
||||
}
|
||||
|
||||
function errorRequest (client, request, err) {
|
||||
try {
|
||||
request.onError(err)
|
||||
assert(request.aborted)
|
||||
} catch (err) {
|
||||
client.emit('error', err)
|
||||
}
|
||||
}
|
||||
|
||||
// https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2
|
||||
function shouldSendContentLength (method) {
|
||||
return method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS' && method !== 'TRACE' && method !== 'CONNECT'
|
||||
@@ -906,7 +884,7 @@ function writeH1 (client, request) {
|
||||
// A user agent may send a Content-Length header with 0 value, this should be allowed.
|
||||
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
|
||||
if (client[kStrictContentLength]) {
|
||||
errorRequest(client, request, new RequestContentLengthMismatchError())
|
||||
util.errorRequest(client, request, new RequestContentLengthMismatchError())
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -915,22 +893,24 @@ function writeH1 (client, request) {
|
||||
|
||||
const socket = client[kSocket]
|
||||
|
||||
const abort = (err) => {
|
||||
if (request.aborted || request.completed) {
|
||||
return
|
||||
}
|
||||
|
||||
util.errorRequest(client, request, err || new RequestAbortedError())
|
||||
|
||||
util.destroy(body)
|
||||
util.destroy(socket, new InformationalError('aborted'))
|
||||
}
|
||||
|
||||
try {
|
||||
request.onConnect((err) => {
|
||||
if (request.aborted || request.completed) {
|
||||
return
|
||||
}
|
||||
|
||||
errorRequest(client, request, err || new RequestAbortedError())
|
||||
|
||||
util.destroy(socket, new InformationalError('aborted'))
|
||||
})
|
||||
request.onConnect(abort)
|
||||
} catch (err) {
|
||||
errorRequest(client, request, err)
|
||||
util.errorRequest(client, request, err)
|
||||
}
|
||||
|
||||
if (request.aborted) {
|
||||
util.destroy(body)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -998,35 +978,19 @@ function writeH1 (client, request) {
|
||||
|
||||
/* istanbul ignore else: assertion */
|
||||
if (!body || bodyLength === 0) {
|
||||
if (contentLength === 0) {
|
||||
socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
|
||||
} else {
|
||||
assert(contentLength === null, 'no body must not have content length')
|
||||
socket.write(`${header}\r\n`, 'latin1')
|
||||
}
|
||||
request.onRequestSent()
|
||||
writeBuffer({ abort, body: null, client, request, socket, contentLength, header, expectsPayload })
|
||||
} else if (util.isBuffer(body)) {
|
||||
assert(contentLength === body.byteLength, 'buffer body must have content length')
|
||||
|
||||
socket.cork()
|
||||
socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
|
||||
socket.write(body)
|
||||
socket.uncork()
|
||||
request.onBodySent(body)
|
||||
request.onRequestSent()
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true
|
||||
}
|
||||
writeBuffer({ abort, body, client, request, socket, contentLength, header, expectsPayload })
|
||||
} else if (util.isBlobLike(body)) {
|
||||
if (typeof body.stream === 'function') {
|
||||
writeIterable({ body: body.stream(), client, request, socket, contentLength, header, expectsPayload })
|
||||
writeIterable({ abort, body: body.stream(), client, request, socket, contentLength, header, expectsPayload })
|
||||
} else {
|
||||
writeBlob({ body, client, request, socket, contentLength, header, expectsPayload })
|
||||
writeBlob({ abort, body, client, request, socket, contentLength, header, expectsPayload })
|
||||
}
|
||||
} else if (util.isStream(body)) {
|
||||
writeStream({ body, client, request, socket, contentLength, header, expectsPayload })
|
||||
writeStream({ abort, body, client, request, socket, contentLength, header, expectsPayload })
|
||||
} else if (util.isIterable(body)) {
|
||||
writeIterable({ body, client, request, socket, contentLength, header, expectsPayload })
|
||||
writeIterable({ abort, body, client, request, socket, contentLength, header, expectsPayload })
|
||||
} else {
|
||||
assert(false)
|
||||
}
|
||||
@@ -1034,12 +998,12 @@ function writeH1 (client, request) {
|
||||
return true
|
||||
}
|
||||
|
||||
function writeStream ({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
function writeStream ({ abort, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
assert(contentLength !== 0 || client[kRunning] === 0, 'stream body cannot be pipelined')
|
||||
|
||||
let finished = false
|
||||
|
||||
const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header })
|
||||
const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header })
|
||||
|
||||
const onData = function (chunk) {
|
||||
if (finished) {
|
||||
@@ -1137,7 +1101,37 @@ function writeStream ({ h2stream, body, client, request, socket, contentLength,
|
||||
}
|
||||
}
|
||||
|
||||
async function writeBlob ({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
async function writeBuffer ({ abort, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
try {
|
||||
if (!body) {
|
||||
if (contentLength === 0) {
|
||||
socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
|
||||
} else {
|
||||
assert(contentLength === null, 'no body must not have content length')
|
||||
socket.write(`${header}\r\n`, 'latin1')
|
||||
}
|
||||
} else if (util.isBuffer(body)) {
|
||||
assert(contentLength === body.byteLength, 'buffer body must have content length')
|
||||
|
||||
socket.cork()
|
||||
socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
|
||||
socket.write(body)
|
||||
socket.uncork()
|
||||
request.onBodySent(body)
|
||||
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true
|
||||
}
|
||||
}
|
||||
request.onRequestSent()
|
||||
|
||||
client[kResume]()
|
||||
} catch (err) {
|
||||
abort(err)
|
||||
}
|
||||
}
|
||||
|
||||
async function writeBlob ({ abort, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
assert(contentLength === body.size, 'blob body must have content length')
|
||||
|
||||
try {
|
||||
@@ -1161,11 +1155,11 @@ async function writeBlob ({ h2stream, body, client, request, socket, contentLeng
|
||||
|
||||
client[kResume]()
|
||||
} catch (err) {
|
||||
util.destroy(socket, err)
|
||||
abort(err)
|
||||
}
|
||||
}
|
||||
|
||||
async function writeIterable ({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
async function writeIterable ({ abort, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
assert(contentLength !== 0 || client[kRunning] === 0, 'iterator body cannot be pipelined')
|
||||
|
||||
let callback = null
|
||||
@@ -1191,7 +1185,7 @@ async function writeIterable ({ h2stream, body, client, request, socket, content
|
||||
.on('close', onDrain)
|
||||
.on('drain', onDrain)
|
||||
|
||||
const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header })
|
||||
const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header })
|
||||
try {
|
||||
// It's up to the user to somehow abort the async iterable.
|
||||
for await (const chunk of body) {
|
||||
@@ -1215,7 +1209,7 @@ async function writeIterable ({ h2stream, body, client, request, socket, content
|
||||
}
|
||||
|
||||
class AsyncWriter {
|
||||
constructor ({ socket, request, contentLength, client, expectsPayload, header }) {
|
||||
constructor ({ abort, socket, request, contentLength, client, expectsPayload, header }) {
|
||||
this.socket = socket
|
||||
this.request = request
|
||||
this.contentLength = contentLength
|
||||
@@ -1223,6 +1217,7 @@ class AsyncWriter {
|
||||
this.bytesWritten = 0
|
||||
this.expectsPayload = expectsPayload
|
||||
this.header = header
|
||||
this.abort = abort
|
||||
|
||||
socket[kWriting] = true
|
||||
}
|
||||
@@ -1338,13 +1333,13 @@ class AsyncWriter {
|
||||
}
|
||||
|
||||
destroy (err) {
|
||||
const { socket, client } = this
|
||||
const { socket, client, abort } = this
|
||||
|
||||
socket[kWriting] = false
|
||||
|
||||
if (err) {
|
||||
assert(client[kRunning] <= 1, 'pipeline should only contain this request')
|
||||
util.destroy(socket, err)
|
||||
abort(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+179
-149
@@ -22,7 +22,6 @@ const {
|
||||
kSocket,
|
||||
kStrictContentLength,
|
||||
kOnError,
|
||||
// HTTP2
|
||||
kMaxConcurrentStreams,
|
||||
kHTTP2Session,
|
||||
kResume
|
||||
@@ -55,14 +54,20 @@ const {
|
||||
} = http2
|
||||
|
||||
function parseH2Headers (headers) {
|
||||
// set-cookie is always an array. Duplicates are added to the array.
|
||||
// For duplicate cookie headers, the values are joined together with '; '.
|
||||
headers = Object.entries(headers).flat(2)
|
||||
|
||||
const result = []
|
||||
|
||||
for (const header of headers) {
|
||||
result.push(Buffer.from(header))
|
||||
for (const [name, value] of Object.entries(headers)) {
|
||||
// h2 may concat the header value by array
|
||||
// e.g. Set-Cookie
|
||||
if (Array.isArray(value)) {
|
||||
for (const subvalue of value) {
|
||||
// we need to provide each header value of header name
|
||||
// because the headers handler expect name-value pair
|
||||
result.push(Buffer.from(name), Buffer.from(subvalue))
|
||||
}
|
||||
} else {
|
||||
result.push(Buffer.from(name), Buffer.from(value))
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
@@ -86,24 +91,55 @@ async function connectH2 (client, socket) {
|
||||
session[kOpenStreams] = 0
|
||||
session[kClient] = client
|
||||
session[kSocket] = socket
|
||||
session.on('error', onHttp2SessionError)
|
||||
session.on('frameError', onHttp2FrameError)
|
||||
session.on('end', onHttp2SessionEnd)
|
||||
session.on('goaway', onHTTP2GoAway)
|
||||
session.on('close', function () {
|
||||
const { [kClient]: client } = this
|
||||
|
||||
util.addListener(session, 'error', onHttp2SessionError)
|
||||
util.addListener(session, 'frameError', onHttp2FrameError)
|
||||
util.addListener(session, 'end', onHttp2SessionEnd)
|
||||
util.addListener(session, 'goaway', onHTTP2GoAway)
|
||||
util.addListener(session, 'close', function () {
|
||||
const { [kClient]: client } = this
|
||||
const { [kSocket]: socket } = client
|
||||
|
||||
const err = this[kSocket][kError] || this[kError] || new SocketError('closed', util.getSocketInfo(socket))
|
||||
|
||||
client[kHTTP2Session] = null
|
||||
|
||||
if (client.destroyed) {
|
||||
assert(client[kPending] === 0)
|
||||
|
||||
// Fail entire queue.
|
||||
const requests = client[kQueue].splice(client[kRunningIdx])
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i]
|
||||
util.errorRequest(client, request, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
session.unref()
|
||||
|
||||
client[kHTTP2Session] = session
|
||||
socket[kHTTP2Session] = session
|
||||
|
||||
util.addListener(socket, 'error', function (err) {
|
||||
assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')
|
||||
|
||||
this[kError] = err
|
||||
|
||||
this[kClient][kOnError](err)
|
||||
})
|
||||
|
||||
util.addListener(socket, 'end', function () {
|
||||
util.destroy(this, new SocketError('other side closed', util.getSocketInfo(this)))
|
||||
})
|
||||
|
||||
util.addListener(socket, 'close', function () {
|
||||
const err = this[kError] || new SocketError('closed', util.getSocketInfo(this))
|
||||
|
||||
client[kSocket] = null
|
||||
|
||||
assert(client[kPending] === 0)
|
||||
|
||||
// Fail entire queue.
|
||||
const requests = client[kQueue].splice(client[kRunningIdx])
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i]
|
||||
errorRequest(client, request, err)
|
||||
if (this[kHTTP2Session] != null) {
|
||||
this[kHTTP2Session].destroy(err)
|
||||
}
|
||||
|
||||
client[kPendingIdx] = client[kRunningIdx]
|
||||
@@ -114,21 +150,6 @@ async function connectH2 (client, socket) {
|
||||
|
||||
client[kResume]()
|
||||
})
|
||||
session.unref()
|
||||
|
||||
client[kHTTP2Session] = session
|
||||
socket[kHTTP2Session] = session
|
||||
|
||||
socket.on('error', function (err) {
|
||||
assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')
|
||||
|
||||
this[kError] = err
|
||||
|
||||
this[kClient][kOnError](err)
|
||||
})
|
||||
socket.on('end', function () {
|
||||
util.destroy(this, new SocketError('other side closed', util.getSocketInfo(this)))
|
||||
})
|
||||
|
||||
let closed = false
|
||||
socket.on('close', () => {
|
||||
@@ -146,10 +167,10 @@ async function connectH2 (client, socket) {
|
||||
|
||||
},
|
||||
destroy (err, callback) {
|
||||
session.destroy(err)
|
||||
if (closed) {
|
||||
queueMicrotask(callback)
|
||||
} else {
|
||||
// Destroying the socket will trigger the session close
|
||||
socket.destroy(err).on('close', callback)
|
||||
}
|
||||
},
|
||||
@@ -166,67 +187,42 @@ function onHttp2SessionError (err) {
|
||||
assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')
|
||||
|
||||
this[kSocket][kError] = err
|
||||
|
||||
this[kClient][kOnError](err)
|
||||
}
|
||||
|
||||
function onHttp2FrameError (type, code, id) {
|
||||
const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`)
|
||||
|
||||
if (id === 0) {
|
||||
const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`)
|
||||
this[kSocket][kError] = err
|
||||
this[kClient][kOnError](err)
|
||||
}
|
||||
}
|
||||
|
||||
function onHttp2SessionEnd () {
|
||||
this.destroy(new SocketError('other side closed'))
|
||||
util.destroy(this[kSocket], new SocketError('other side closed'))
|
||||
const err = new SocketError('other side closed', util.getSocketInfo(this[kSocket]))
|
||||
this.destroy(err)
|
||||
util.destroy(this[kSocket], err)
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the root cause of #3011
|
||||
* We need to handle GOAWAY frames properly, and trigger the session close
|
||||
* along with the socket right away
|
||||
* Find a way to trigger the close cycle from here on.
|
||||
*/
|
||||
function onHTTP2GoAway (code) {
|
||||
const client = this[kClient]
|
||||
const err = new InformationalError(`HTTP/2: "GOAWAY" frame received with code ${code}`)
|
||||
client[kSocket] = null
|
||||
client[kHTTP2Session] = null
|
||||
|
||||
if (client.destroyed) {
|
||||
assert(this[kPending] === 0)
|
||||
// We need to trigger the close cycle right away
|
||||
// We need to destroy the session and the socket
|
||||
// Requests should be failed with the error after the current one is handled
|
||||
this[kSocket][kError] = err
|
||||
this[kClient][kOnError](err)
|
||||
|
||||
// Fail entire queue.
|
||||
const requests = client[kQueue].splice(client[kRunningIdx])
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i]
|
||||
errorRequest(this, request, err)
|
||||
}
|
||||
} else if (client[kRunning] > 0) {
|
||||
// Fail head of pipeline.
|
||||
const request = client[kQueue][client[kRunningIdx]]
|
||||
client[kQueue][client[kRunningIdx]++] = null
|
||||
|
||||
errorRequest(client, request, err)
|
||||
}
|
||||
|
||||
client[kPendingIdx] = client[kRunningIdx]
|
||||
|
||||
assert(client[kRunning] === 0)
|
||||
|
||||
client.emit('disconnect',
|
||||
client[kUrl],
|
||||
[client],
|
||||
err
|
||||
)
|
||||
|
||||
client[kResume]()
|
||||
}
|
||||
|
||||
function errorRequest (client, request, err) {
|
||||
try {
|
||||
request.onError(err)
|
||||
assert(request.aborted)
|
||||
} catch (err) {
|
||||
client.emit('error', err)
|
||||
}
|
||||
this.unref()
|
||||
// We send the GOAWAY frame response as no error
|
||||
this.destroy()
|
||||
util.destroy(this[kSocket], err)
|
||||
}
|
||||
|
||||
// https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2
|
||||
@@ -239,7 +235,7 @@ function writeH2 (client, request) {
|
||||
const { body, method, path, host, upgrade, expectContinue, signal, headers: reqHeaders } = request
|
||||
|
||||
if (upgrade) {
|
||||
errorRequest(client, request, new Error('Upgrade not supported for H2'))
|
||||
util.errorRequest(client, request, new Error('Upgrade not supported for H2'))
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -273,29 +269,30 @@ function writeH2 (client, request) {
|
||||
headers[HTTP2_HEADER_AUTHORITY] = host || `${hostname}${port ? `:${port}` : ''}`
|
||||
headers[HTTP2_HEADER_METHOD] = method
|
||||
|
||||
const abort = (err) => {
|
||||
if (request.aborted || request.completed) {
|
||||
return
|
||||
}
|
||||
|
||||
err = err || new RequestAbortedError()
|
||||
|
||||
util.errorRequest(client, request, err)
|
||||
|
||||
if (stream != null) {
|
||||
util.destroy(stream, err)
|
||||
}
|
||||
|
||||
// We do not destroy the socket as we can continue using the session
|
||||
// the stream get's destroyed and the session remains to create new streams
|
||||
util.destroy(body, err)
|
||||
}
|
||||
|
||||
try {
|
||||
// We are already connected, streams are pending.
|
||||
// We can call on connect, and wait for abort
|
||||
request.onConnect((err) => {
|
||||
if (request.aborted || request.completed) {
|
||||
return
|
||||
}
|
||||
|
||||
err = err || new RequestAbortedError()
|
||||
|
||||
if (stream != null) {
|
||||
util.destroy(stream, err)
|
||||
|
||||
session[kOpenStreams] -= 1
|
||||
if (session[kOpenStreams] === 0) {
|
||||
session.unref()
|
||||
}
|
||||
}
|
||||
|
||||
errorRequest(client, request, err)
|
||||
})
|
||||
request.onConnect(abort)
|
||||
} catch (err) {
|
||||
errorRequest(client, request, err)
|
||||
util.errorRequest(client, request, err)
|
||||
}
|
||||
|
||||
if (method === 'CONNECT') {
|
||||
@@ -318,7 +315,6 @@ function writeH2 (client, request) {
|
||||
|
||||
stream.once('close', () => {
|
||||
session[kOpenStreams] -= 1
|
||||
// TODO(HTTP/2): unref only if current streams count is 0
|
||||
if (session[kOpenStreams] === 0) session.unref()
|
||||
})
|
||||
|
||||
@@ -370,7 +366,7 @@ function writeH2 (client, request) {
|
||||
// A user agent may send a Content-Length header with 0 value, this should be allowed.
|
||||
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength != null && request.contentLength !== contentLength) {
|
||||
if (client[kStrictContentLength]) {
|
||||
errorRequest(client, request, new RequestContentLengthMismatchError())
|
||||
util.errorRequest(client, request, new RequestContentLengthMismatchError())
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -398,7 +394,7 @@ function writeH2 (client, request) {
|
||||
writeBodyH2()
|
||||
}
|
||||
|
||||
// Increment counter as we have new several streams open
|
||||
// Increment counter as we have new streams open
|
||||
++session[kOpenStreams]
|
||||
|
||||
stream.once('response', headers => {
|
||||
@@ -410,9 +406,9 @@ function writeH2 (client, request) {
|
||||
// the request remains in-flight and headers hasn't been received yet
|
||||
// for those scenarios, best effort is to destroy the stream immediately
|
||||
// as there's no value to keep it open.
|
||||
if (request.aborted || request.completed) {
|
||||
if (request.aborted) {
|
||||
const err = new RequestAbortedError()
|
||||
errorRequest(client, request, err)
|
||||
util.errorRequest(client, request, err)
|
||||
util.destroy(stream, err)
|
||||
return
|
||||
}
|
||||
@@ -440,39 +436,26 @@ function writeH2 (client, request) {
|
||||
// Stream is closed or half-closed-remote (6), decrement counter and cleanup
|
||||
// It does not have sense to continue working with the stream as we do not
|
||||
// have yet RST_STREAM support on client-side
|
||||
session[kOpenStreams] -= 1
|
||||
if (session[kOpenStreams] === 0) {
|
||||
session.unref()
|
||||
}
|
||||
|
||||
const err = new InformationalError('HTTP/2: stream half-closed (remote)')
|
||||
errorRequest(client, request, err)
|
||||
util.destroy(stream, err)
|
||||
abort(new InformationalError('HTTP/2: stream half-closed (remote)'))
|
||||
})
|
||||
|
||||
stream.once('close', () => {
|
||||
session[kOpenStreams] -= 1
|
||||
// TODO(HTTP/2): unref only if current streams count is 0
|
||||
if (session[kOpenStreams] === 0) {
|
||||
session.unref()
|
||||
}
|
||||
})
|
||||
|
||||
stream.once('error', function (err) {
|
||||
if (client[kHTTP2Session] && !client[kHTTP2Session].destroyed && !this.closed && !this.destroyed) {
|
||||
session[kOpenStreams] -= 1
|
||||
util.destroy(stream, err)
|
||||
}
|
||||
abort(err)
|
||||
})
|
||||
|
||||
stream.once('frameError', (type, code) => {
|
||||
const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`)
|
||||
errorRequest(client, request, err)
|
||||
|
||||
if (client[kHTTP2Session] && !client[kHTTP2Session].destroyed && !this.closed && !this.destroyed) {
|
||||
session[kOpenStreams] -= 1
|
||||
util.destroy(stream, err)
|
||||
}
|
||||
abort(new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`))
|
||||
})
|
||||
|
||||
// stream.on('aborted', () => {
|
||||
@@ -495,37 +478,49 @@ function writeH2 (client, request) {
|
||||
|
||||
function writeBodyH2 () {
|
||||
/* istanbul ignore else: assertion */
|
||||
if (!body) {
|
||||
request.onRequestSent()
|
||||
if (!body || contentLength === 0) {
|
||||
writeBuffer({
|
||||
abort,
|
||||
client,
|
||||
request,
|
||||
contentLength,
|
||||
expectsPayload,
|
||||
h2stream: stream,
|
||||
body: null,
|
||||
socket: client[kSocket]
|
||||
})
|
||||
} else if (util.isBuffer(body)) {
|
||||
assert(contentLength === body.byteLength, 'buffer body must have content length')
|
||||
stream.cork()
|
||||
stream.write(body)
|
||||
stream.uncork()
|
||||
stream.end()
|
||||
request.onBodySent(body)
|
||||
request.onRequestSent()
|
||||
writeBuffer({
|
||||
abort,
|
||||
client,
|
||||
request,
|
||||
contentLength,
|
||||
body,
|
||||
expectsPayload,
|
||||
h2stream: stream,
|
||||
socket: client[kSocket]
|
||||
})
|
||||
} else if (util.isBlobLike(body)) {
|
||||
if (typeof body.stream === 'function') {
|
||||
writeIterable({
|
||||
abort,
|
||||
client,
|
||||
request,
|
||||
contentLength,
|
||||
h2stream: stream,
|
||||
expectsPayload,
|
||||
h2stream: stream,
|
||||
body: body.stream(),
|
||||
socket: client[kSocket],
|
||||
header: ''
|
||||
socket: client[kSocket]
|
||||
})
|
||||
} else {
|
||||
writeBlob({
|
||||
abort,
|
||||
body,
|
||||
client,
|
||||
request,
|
||||
contentLength,
|
||||
expectsPayload,
|
||||
h2stream: stream,
|
||||
header: '',
|
||||
socket: client[kSocket]
|
||||
})
|
||||
}
|
||||
@@ -557,7 +552,30 @@ function writeH2 (client, request) {
|
||||
}
|
||||
}
|
||||
|
||||
function writeStream ({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
function writeBuffer ({ abort, h2stream, body, client, request, socket, contentLength, expectsPayload }) {
|
||||
try {
|
||||
if (body != null && util.isBuffer(body)) {
|
||||
assert(contentLength === body.byteLength, 'buffer body must have content length')
|
||||
h2stream.cork()
|
||||
h2stream.write(body)
|
||||
h2stream.uncork()
|
||||
h2stream.end()
|
||||
|
||||
request.onBodySent(body)
|
||||
}
|
||||
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true
|
||||
}
|
||||
|
||||
request.onRequestSent()
|
||||
client[kResume]()
|
||||
} catch (error) {
|
||||
abort(error)
|
||||
}
|
||||
}
|
||||
|
||||
function writeStream ({ abort, socket, expectsPayload, h2stream, body, client, request, contentLength }) {
|
||||
assert(contentLength !== 0 || client[kRunning] === 0, 'stream body cannot be pipelined')
|
||||
|
||||
// For HTTP/2, is enough to pipe the stream
|
||||
@@ -566,26 +584,29 @@ function writeStream ({ h2stream, body, client, request, socket, contentLength,
|
||||
h2stream,
|
||||
(err) => {
|
||||
if (err) {
|
||||
util.destroy(body, err)
|
||||
util.destroy(h2stream, err)
|
||||
util.destroy(pipe, err)
|
||||
abort(err)
|
||||
} else {
|
||||
util.removeAllListeners(pipe)
|
||||
request.onRequestSent()
|
||||
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true
|
||||
}
|
||||
|
||||
client[kResume]()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
pipe.on('data', onPipeData)
|
||||
pipe.once('end', () => {
|
||||
pipe.removeListener('data', onPipeData)
|
||||
util.destroy(pipe)
|
||||
})
|
||||
util.addListener(pipe, 'data', onPipeData)
|
||||
|
||||
function onPipeData (chunk) {
|
||||
request.onBodySent(chunk)
|
||||
}
|
||||
}
|
||||
|
||||
async function writeBlob ({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
async function writeBlob ({ abort, h2stream, body, client, request, socket, contentLength, expectsPayload }) {
|
||||
assert(contentLength === body.size, 'blob body must have content length')
|
||||
|
||||
try {
|
||||
@@ -598,6 +619,7 @@ async function writeBlob ({ h2stream, body, client, request, socket, contentLeng
|
||||
h2stream.cork()
|
||||
h2stream.write(buffer)
|
||||
h2stream.uncork()
|
||||
h2stream.end()
|
||||
|
||||
request.onBodySent(buffer)
|
||||
request.onRequestSent()
|
||||
@@ -608,11 +630,11 @@ async function writeBlob ({ h2stream, body, client, request, socket, contentLeng
|
||||
|
||||
client[kResume]()
|
||||
} catch (err) {
|
||||
util.destroy(h2stream)
|
||||
abort(err)
|
||||
}
|
||||
}
|
||||
|
||||
async function writeIterable ({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
async function writeIterable ({ abort, h2stream, body, client, request, socket, contentLength, expectsPayload }) {
|
||||
assert(contentLength !== 0 || client[kRunning] === 0, 'iterator body cannot be pipelined')
|
||||
|
||||
let callback = null
|
||||
@@ -651,11 +673,19 @@ async function writeIterable ({ h2stream, body, client, request, socket, content
|
||||
await waitForDrain()
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
h2stream.destroy(err)
|
||||
} finally {
|
||||
request.onRequestSent()
|
||||
|
||||
h2stream.end()
|
||||
|
||||
request.onRequestSent()
|
||||
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true
|
||||
}
|
||||
|
||||
client[kResume]()
|
||||
} catch (err) {
|
||||
abort(err)
|
||||
} finally {
|
||||
h2stream
|
||||
.off('close', onDrain)
|
||||
.off('drain', onDrain)
|
||||
|
||||
+7
-13
@@ -338,7 +338,7 @@ class Client extends DispatcherBase {
|
||||
const requests = this[kQueue].splice(this[kPendingIdx])
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i]
|
||||
errorRequest(this, request, err)
|
||||
util.errorRequest(this, request, err)
|
||||
}
|
||||
|
||||
const callback = () => {
|
||||
@@ -378,7 +378,7 @@ function onError (client, err) {
|
||||
const requests = client[kQueue].splice(client[kRunningIdx])
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i]
|
||||
errorRequest(client, request, err)
|
||||
util.errorRequest(client, request, err)
|
||||
}
|
||||
assert(client[kSize] === 0)
|
||||
}
|
||||
@@ -502,7 +502,7 @@ async function connect (client) {
|
||||
assert(client[kRunning] === 0)
|
||||
while (client[kPending] > 0 && client[kQueue][client[kPendingIdx]].servername === client[kServerName]) {
|
||||
const request = client[kQueue][client[kPendingIdx]++]
|
||||
errorRequest(client, request, err)
|
||||
util.errorRequest(client, request, err)
|
||||
}
|
||||
} else {
|
||||
onError(client, err)
|
||||
@@ -581,7 +581,10 @@ function _resume (client, sync) {
|
||||
}
|
||||
|
||||
client[kServerName] = request.servername
|
||||
client[kHTTPContext]?.destroy(new InformationalError('servername changed'))
|
||||
client[kHTTPContext]?.destroy(new InformationalError('servername changed'), () => {
|
||||
client[kHTTPContext] = null
|
||||
resume(client)
|
||||
})
|
||||
}
|
||||
|
||||
if (client[kConnecting]) {
|
||||
@@ -609,13 +612,4 @@ function _resume (client, sync) {
|
||||
}
|
||||
}
|
||||
|
||||
function errorRequest (client, request, err) {
|
||||
try {
|
||||
request.onError(err)
|
||||
assert(request.aborted)
|
||||
} catch (err) {
|
||||
client.emit('error', err)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client
|
||||
+11
-9
@@ -64,19 +64,19 @@ class ProxyAgent extends DispatcherBase {
|
||||
this[kAgent] = new Agent({
|
||||
...opts,
|
||||
connect: async (opts, callback) => {
|
||||
let requestedHost = opts.host
|
||||
let requestedPath = opts.host
|
||||
if (!opts.port) {
|
||||
requestedHost += `:${defaultProtocolPort(opts.protocol)}`
|
||||
requestedPath += `:${defaultProtocolPort(opts.protocol)}`
|
||||
}
|
||||
try {
|
||||
const { socket, statusCode } = await this[kClient].connect({
|
||||
origin,
|
||||
port,
|
||||
path: requestedHost,
|
||||
path: requestedPath,
|
||||
signal: opts.signal,
|
||||
headers: {
|
||||
...this[kProxyHeaders],
|
||||
host: requestedHost
|
||||
host: opts.host
|
||||
},
|
||||
servername: this[kProxyTls]?.servername || proxyHostname
|
||||
})
|
||||
@@ -108,16 +108,18 @@ class ProxyAgent extends DispatcherBase {
|
||||
}
|
||||
|
||||
dispatch (opts, handler) {
|
||||
const { host } = new URL(opts.origin)
|
||||
const headers = buildHeaders(opts.headers)
|
||||
throwIfProxyAuthIsSent(headers)
|
||||
|
||||
if (headers && !('host' in headers) && !('Host' in headers)) {
|
||||
const { host } = new URL(opts.origin)
|
||||
headers.host = host
|
||||
}
|
||||
|
||||
return this[kAgent].dispatch(
|
||||
{
|
||||
...opts,
|
||||
headers: {
|
||||
...headers,
|
||||
host
|
||||
}
|
||||
headers
|
||||
},
|
||||
handler
|
||||
)
|
||||
|
||||
+17
-8
@@ -1,35 +1,44 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = class DecoratorHandler {
|
||||
#handler
|
||||
|
||||
constructor (handler) {
|
||||
this.handler = handler
|
||||
if (typeof handler !== 'object' || handler === null) {
|
||||
throw new TypeError('handler must be an object')
|
||||
}
|
||||
this.#handler = handler
|
||||
}
|
||||
|
||||
onConnect (...args) {
|
||||
return this.handler.onConnect(...args)
|
||||
return this.#handler.onConnect?.(...args)
|
||||
}
|
||||
|
||||
onError (...args) {
|
||||
return this.handler.onError(...args)
|
||||
return this.#handler.onError?.(...args)
|
||||
}
|
||||
|
||||
onUpgrade (...args) {
|
||||
return this.handler.onUpgrade(...args)
|
||||
return this.#handler.onUpgrade?.(...args)
|
||||
}
|
||||
|
||||
onResponseStarted (...args) {
|
||||
return this.#handler.onResponseStarted?.(...args)
|
||||
}
|
||||
|
||||
onHeaders (...args) {
|
||||
return this.handler.onHeaders(...args)
|
||||
return this.#handler.onHeaders?.(...args)
|
||||
}
|
||||
|
||||
onData (...args) {
|
||||
return this.handler.onData(...args)
|
||||
return this.#handler.onData?.(...args)
|
||||
}
|
||||
|
||||
onComplete (...args) {
|
||||
return this.handler.onComplete(...args)
|
||||
return this.#handler.onComplete?.(...args)
|
||||
}
|
||||
|
||||
onBodySent (...args) {
|
||||
return this.handler.onBodySent(...args)
|
||||
return this.#handler.onBodySent?.(...args)
|
||||
}
|
||||
}
|
||||
+18
-17
@@ -90,7 +90,7 @@ class MockInterceptor {
|
||||
this[kContentLength] = false
|
||||
}
|
||||
|
||||
createMockScopeDispatchData (statusCode, data, responseOptions = {}) {
|
||||
createMockScopeDispatchData ({ statusCode, data, responseOptions }) {
|
||||
const responseData = getResponseData(data)
|
||||
const contentLength = this[kContentLength] ? { 'content-length': responseData.length } : {}
|
||||
const headers = { ...this[kDefaultHeaders], ...contentLength, ...responseOptions.headers }
|
||||
@@ -99,14 +99,11 @@ class MockInterceptor {
|
||||
return { statusCode, data, headers, trailers }
|
||||
}
|
||||
|
||||
validateReplyParameters (statusCode, data, responseOptions) {
|
||||
if (typeof statusCode === 'undefined') {
|
||||
validateReplyParameters (replyParameters) {
|
||||
if (typeof replyParameters.statusCode === 'undefined') {
|
||||
throw new InvalidArgumentError('statusCode must be defined')
|
||||
}
|
||||
if (typeof data === 'undefined') {
|
||||
throw new InvalidArgumentError('data must be defined')
|
||||
}
|
||||
if (typeof responseOptions !== 'object' || responseOptions === null) {
|
||||
if (typeof replyParameters.responseOptions !== 'object' || replyParameters.responseOptions === null) {
|
||||
throw new InvalidArgumentError('responseOptions must be an object')
|
||||
}
|
||||
}
|
||||
@@ -114,28 +111,28 @@ class MockInterceptor {
|
||||
/**
|
||||
* Mock an undici request with a defined reply.
|
||||
*/
|
||||
reply (replyData) {
|
||||
reply (replyOptionsCallbackOrStatusCode) {
|
||||
// Values of reply aren't available right now as they
|
||||
// can only be available when the reply callback is invoked.
|
||||
if (typeof replyData === 'function') {
|
||||
if (typeof replyOptionsCallbackOrStatusCode === 'function') {
|
||||
// We'll first wrap the provided callback in another function,
|
||||
// this function will properly resolve the data from the callback
|
||||
// when invoked.
|
||||
const wrappedDefaultsCallback = (opts) => {
|
||||
// Our reply options callback contains the parameter for statusCode, data and options.
|
||||
const resolvedData = replyData(opts)
|
||||
const resolvedData = replyOptionsCallbackOrStatusCode(opts)
|
||||
|
||||
// Check if it is in the right format
|
||||
if (typeof resolvedData !== 'object') {
|
||||
if (typeof resolvedData !== 'object' || resolvedData === null) {
|
||||
throw new InvalidArgumentError('reply options callback must return an object')
|
||||
}
|
||||
|
||||
const { statusCode, data = '', responseOptions = {} } = resolvedData
|
||||
this.validateReplyParameters(statusCode, data, responseOptions)
|
||||
const replyParameters = { data: '', responseOptions: {}, ...resolvedData }
|
||||
this.validateReplyParameters(replyParameters)
|
||||
// Since the values can be obtained immediately we return them
|
||||
// from this higher order function that will be resolved later.
|
||||
return {
|
||||
...this.createMockScopeDispatchData(statusCode, data, responseOptions)
|
||||
...this.createMockScopeDispatchData(replyParameters)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,11 +145,15 @@ class MockInterceptor {
|
||||
// we should have 1-3 parameters. So we spread the arguments of
|
||||
// this function to obtain the parameters, since replyData will always
|
||||
// just be the statusCode.
|
||||
const [statusCode, data = '', responseOptions = {}] = [...arguments]
|
||||
this.validateReplyParameters(statusCode, data, responseOptions)
|
||||
const replyParameters = {
|
||||
statusCode: replyOptionsCallbackOrStatusCode,
|
||||
data: arguments[1] === undefined ? '' : arguments[1],
|
||||
responseOptions: arguments[2] === undefined ? {} : arguments[2]
|
||||
}
|
||||
this.validateReplyParameters(replyParameters)
|
||||
|
||||
// Send in-already provided data like usual
|
||||
const dispatchData = this.createMockScopeDispatchData(statusCode, data, responseOptions)
|
||||
const dispatchData = this.createMockScopeDispatchData(replyParameters)
|
||||
const newMockDispatch = addMockDispatch(this[kDispatches], this[kDispatchKey], dispatchData)
|
||||
return new MockScope(newMockDispatch)
|
||||
}
|
||||
|
||||
+5
-5
@@ -8,7 +8,7 @@ const {
|
||||
kOrigin,
|
||||
kGetNetConnect
|
||||
} = require('./mock-symbols')
|
||||
const { buildURL, nop } = require('../core/util')
|
||||
const { buildURL } = require('../core/util')
|
||||
const { STATUS_CODES } = require('node:http')
|
||||
const {
|
||||
types: {
|
||||
@@ -285,10 +285,10 @@ function mockDispatch (opts, handler) {
|
||||
const responseHeaders = generateKeyValues(headers)
|
||||
const responseTrailers = generateKeyValues(trailers)
|
||||
|
||||
handler.abort = nop
|
||||
handler.onHeaders(statusCode, responseHeaders, resume, getStatusText(statusCode))
|
||||
handler.onData(Buffer.from(responseData))
|
||||
handler.onComplete(responseTrailers)
|
||||
handler.onConnect?.(err => handler.onError(err), null)
|
||||
handler.onHeaders?.(statusCode, responseHeaders, resume, getStatusText(statusCode))
|
||||
handler.onData?.(Buffer.from(responseData))
|
||||
handler.onComplete?.(responseTrailers)
|
||||
deleteMockDispatch(mockDispatches, key)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -403,14 +403,14 @@ function mixinBody (prototype) {
|
||||
async function consumeBody (object, convertBytesToJSValue, instance) {
|
||||
webidl.brandCheck(object, instance)
|
||||
|
||||
throwIfAborted(object[kState])
|
||||
|
||||
// 1. If object is unusable, then return a promise rejected
|
||||
// with a TypeError.
|
||||
if (bodyUnusable(object[kState].body)) {
|
||||
throw new TypeError('Body is unusable')
|
||||
}
|
||||
|
||||
throwIfAborted(object[kState])
|
||||
|
||||
// 2. Let promise be a new promise.
|
||||
const promise = createDeferredPromise()
|
||||
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ const badPorts = [
|
||||
'87', '95', '101', '102', '103', '104', '109', '110', '111', '113', '115', '117', '119', '123', '135', '137',
|
||||
'139', '143', '161', '179', '389', '427', '465', '512', '513', '514', '515', '526', '530', '531', '532',
|
||||
'540', '548', '554', '556', '563', '587', '601', '636', '989', '990', '993', '995', '1719', '1720', '1723',
|
||||
'2049', '3659', '4045', '5060', '5061', '6000', '6566', '6665', '6666', '6667', '6668', '6669', '6697',
|
||||
'10080'
|
||||
'2049', '3659', '4045', '4190', '5060', '5061', '6000', '6566', '6665', '6666', '6667', '6668', '6669', '6679',
|
||||
'6697', '10080'
|
||||
]
|
||||
|
||||
const badPortsSet = new Set(badPorts)
|
||||
|
||||
+2
-40
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const { toUSVString, isUSVString, bufferToLowerCasedHeaderName } = require('../../core/util')
|
||||
const { isUSVString, bufferToLowerCasedHeaderName } = require('../../core/util')
|
||||
const { utf8DecodeBytes } = require('./util')
|
||||
const { HTTP_TOKEN_CODEPOINTS, isomorphicDecode } = require('./data-url')
|
||||
const { isFileLike, File: UndiciFile } = require('./file')
|
||||
@@ -60,43 +60,6 @@ function validateBoundary (boundary) {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://andreubotella.github.io/multipart-form-data/#escape-a-multipart-form-data-name
|
||||
* @param {string} name
|
||||
* @param {string} [encoding='utf-8']
|
||||
* @param {boolean} [isFilename=false]
|
||||
*/
|
||||
function escapeFormDataName (name, encoding = 'utf-8', isFilename = false) {
|
||||
// 1. If isFilename is true:
|
||||
if (isFilename) {
|
||||
// 1.1. Set name to the result of converting name into a scalar value string.
|
||||
name = toUSVString(name)
|
||||
} else {
|
||||
// 2. Otherwise:
|
||||
|
||||
// 2.1. Assert: name is a scalar value string.
|
||||
assert(isUSVString(name))
|
||||
|
||||
// 2.2. Replace every occurrence of U+000D (CR) not followed by U+000A (LF),
|
||||
// and every occurrence of U+000A (LF) not preceded by U+000D (CR), in
|
||||
// name, by a string consisting of U+000D (CR) and U+000A (LF).
|
||||
name = name.replace(/\r\n?|\r?\n/g, '\r\n')
|
||||
}
|
||||
|
||||
// 3. Let encoded be the result of encoding name with encoding.
|
||||
assert(Buffer.isEncoding(encoding))
|
||||
|
||||
// 4. Replace every 0x0A (LF) bytes in encoded with the byte sequence `%0A`,
|
||||
// 0x0D (CR) with `%0D` and 0x22 (") with `%22`.
|
||||
name = name
|
||||
.replace(/\n/g, '%0A')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/"/g, '%22')
|
||||
|
||||
// 5. Return encoded.
|
||||
return Buffer.from(name, encoding) // encoded
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://andreubotella.github.io/multipart-form-data/#multipart-form-data-parser
|
||||
* @param {Buffer} input
|
||||
@@ -497,6 +460,5 @@ function bufferStartsWith (buffer, start, position) {
|
||||
|
||||
module.exports = {
|
||||
multipartFormDataParser,
|
||||
validateBoundary,
|
||||
escapeFormDataName
|
||||
validateBoundary
|
||||
}
|
||||
+7
-30
@@ -58,7 +58,7 @@ const {
|
||||
subresourceSet
|
||||
} = require('./constants')
|
||||
const EE = require('node:events')
|
||||
const { Readable, pipeline } = require('node:stream')
|
||||
const { Readable, pipeline, finished } = require('node:stream')
|
||||
const { addAbortListener, isErrored, isReadable, nodeMajor, nodeMinor, bufferToLowerCasedHeaderName } = require('../../core/util')
|
||||
const { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require('./data-url')
|
||||
const { getGlobalDispatcher } = require('../../global')
|
||||
@@ -1080,42 +1080,19 @@ function fetchFinale (fetchParams, response) {
|
||||
if (internalResponse.body == null) {
|
||||
processResponseEndOfBody()
|
||||
} else {
|
||||
// mcollina: all the following steps of the specs are skipped.
|
||||
// The internal transform stream is not needed.
|
||||
// See https://github.com/nodejs/undici/pull/3093#issuecomment-2050198541
|
||||
|
||||
// 1. Let transformStream be a new TransformStream.
|
||||
// 2. Let identityTransformAlgorithm be an algorithm which, given chunk, enqueues chunk in transformStream.
|
||||
// 3. Set up transformStream with transformAlgorithm set to identityTransformAlgorithm and flushAlgorithm
|
||||
// set to processResponseEndOfBody.
|
||||
const transformStream = new TransformStream({
|
||||
start () { },
|
||||
transform (chunk, controller) {
|
||||
controller.enqueue(chunk)
|
||||
},
|
||||
flush: processResponseEndOfBody
|
||||
})
|
||||
|
||||
// 4. Set internalResponse’s body’s stream to the result of internalResponse’s body’s stream piped through transformStream.
|
||||
internalResponse.body.stream.pipeThrough(transformStream)
|
||||
|
||||
const byteStream = new ReadableStream({
|
||||
readableStream: transformStream.readable,
|
||||
async start () {
|
||||
this._bodyReader = this.readableStream.getReader()
|
||||
},
|
||||
async pull (controller) {
|
||||
while (controller.desiredSize >= 0) {
|
||||
const { done, value } = await this._bodyReader.read()
|
||||
|
||||
if (done) {
|
||||
queueMicrotask(() => readableStreamClose(controller))
|
||||
break
|
||||
}
|
||||
|
||||
controller.enqueue(value)
|
||||
}
|
||||
},
|
||||
type: 'bytes'
|
||||
finished(internalResponse.body.stream, () => {
|
||||
processResponseEndOfBody()
|
||||
})
|
||||
|
||||
internalResponse.body.stream = byteStream
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-30
@@ -72,14 +72,13 @@ function responseLocationURL (response, requestFragment) {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isValidEncodedURL (url) {
|
||||
for (const c of url) {
|
||||
const code = c.charCodeAt(0)
|
||||
// Not used in US-ASCII
|
||||
if (code >= 0x80) {
|
||||
return false
|
||||
}
|
||||
// Control characters
|
||||
if ((code >= 0x00 && code <= 0x1F) || code === 0x7F) {
|
||||
for (let i = 0; i < url.length; ++i) {
|
||||
const code = url.charCodeAt(i)
|
||||
|
||||
if (
|
||||
code > 0x7E || // Non-US-ASCII + DEL
|
||||
code < 0x20 // Control characters NUL - US
|
||||
) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -159,24 +158,15 @@ const isValidHeaderName = isValidHTTPToken
|
||||
function isValidHeaderValue (potentialValue) {
|
||||
// - Has no leading or trailing HTTP tab or space bytes.
|
||||
// - Contains no 0x00 (NUL) or HTTP newline bytes.
|
||||
if (
|
||||
potentialValue.startsWith('\t') ||
|
||||
potentialValue.startsWith(' ') ||
|
||||
potentialValue.endsWith('\t') ||
|
||||
potentialValue.endsWith(' ')
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (
|
||||
potentialValue.includes('\0') ||
|
||||
return (
|
||||
potentialValue[0] === '\t' ||
|
||||
potentialValue[0] === ' ' ||
|
||||
potentialValue[potentialValue.length - 1] === '\t' ||
|
||||
potentialValue[potentialValue.length - 1] === ' ' ||
|
||||
potentialValue.includes('\n') ||
|
||||
potentialValue.includes('\r') ||
|
||||
potentialValue.includes('\n')
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
potentialValue.includes('\0')
|
||||
) === false
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webappsec-referrer-policy/#set-requests-referrer-policy-on-redirect
|
||||
@@ -1168,13 +1158,21 @@ function urlIsLocal (url) {
|
||||
|
||||
/**
|
||||
* @param {string|URL} url
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function urlHasHttpsScheme (url) {
|
||||
if (typeof url === 'string') {
|
||||
return url.startsWith('https:')
|
||||
}
|
||||
|
||||
return url.protocol === 'https:'
|
||||
return (
|
||||
(
|
||||
typeof url === 'string' &&
|
||||
url[5] === ':' &&
|
||||
url[0] === 'h' &&
|
||||
url[1] === 't' &&
|
||||
url[2] === 't' &&
|
||||
url[3] === 'p' &&
|
||||
url[4] === 's'
|
||||
) ||
|
||||
url.protocol === 'https:'
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1566,6 +1564,7 @@ function utf8DecodeBytes (buffer) {
|
||||
module.exports = {
|
||||
isAborted,
|
||||
isCancelled,
|
||||
isValidEncodedURL,
|
||||
createDeferredPromise,
|
||||
ReadableStreamFrom,
|
||||
tryUpgradeRequestToAPotentiallyTrustworthyURL,
|
||||
|
||||
+2
-3
@@ -4,7 +4,7 @@ const { Writable } = require('node:stream')
|
||||
const { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require('./constants')
|
||||
const { kReadyState, kSentClose, kResponse, kReceivedClose } = require('./symbols')
|
||||
const { channels } = require('../../core/diagnostics')
|
||||
const { isValidStatusCode, failWebsocketConnection, websocketMessageReceived } = require('./util')
|
||||
const { isValidStatusCode, failWebsocketConnection, websocketMessageReceived, utf8Decode } = require('./util')
|
||||
const { WebsocketFrameSend } = require('./frame')
|
||||
|
||||
// This code was influenced by ws released under the MIT license.
|
||||
@@ -314,8 +314,7 @@ class ByteParser extends Writable {
|
||||
}
|
||||
|
||||
try {
|
||||
// TODO: optimize this
|
||||
reason = new TextDecoder('utf-8', { fatal: true }).decode(reason)
|
||||
reason = utf8Decode(reason)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
|
||||
+28
-2
@@ -3,6 +3,7 @@
|
||||
const { kReadyState, kController, kResponse, kBinaryType, kWebSocketURL } = require('./symbols')
|
||||
const { states, opcodes } = require('./constants')
|
||||
const { MessageEvent, ErrorEvent } = require('./events')
|
||||
const { isUtf8 } = require('node:buffer')
|
||||
|
||||
/* globals Blob */
|
||||
|
||||
@@ -87,7 +88,7 @@ function websocketMessageReceived (ws, type, data) {
|
||||
// -> type indicates that the data is Text
|
||||
// a new DOMString containing data
|
||||
try {
|
||||
dataForEvent = new TextDecoder('utf-8', { fatal: true }).decode(data)
|
||||
dataForEvent = utf8Decode(data)
|
||||
} catch {
|
||||
failWebsocketConnection(ws, 'Received invalid UTF-8 in text frame.')
|
||||
return
|
||||
@@ -200,6 +201,30 @@ function failWebsocketConnection (ws, reason) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://nodejs.org/api/intl.html#detecting-internationalization-support
|
||||
const hasIntl = typeof process.versions.icu === 'string'
|
||||
const fatalDecoder = hasIntl ? new TextDecoder('utf-8', { fatal: true }) : undefined
|
||||
|
||||
/**
|
||||
* Converts a Buffer to utf-8, even on platforms without icu.
|
||||
* @param {Buffer} buffer
|
||||
*/
|
||||
const utf8Decode = hasIntl
|
||||
? fatalDecoder.decode.bind(fatalDecoder)
|
||||
: !isUtf8
|
||||
? function () { // TODO: remove once node 18 or < node v18.14.0 is dropped
|
||||
process.emitWarning('ICU is not supported and no fallback exists. Please upgrade to at least Node v18.14.0.', {
|
||||
code: 'UNDICI-WS-NO-ICU'
|
||||
})
|
||||
throw new TypeError('Invalid utf-8 received.')
|
||||
}
|
||||
: function (buffer) {
|
||||
if (isUtf8(buffer)) {
|
||||
return buffer.toString('utf-8')
|
||||
}
|
||||
throw new TypeError('Invalid utf-8 received.')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isConnecting,
|
||||
isEstablished,
|
||||
@@ -209,5 +234,6 @@ module.exports = {
|
||||
isValidSubprotocol,
|
||||
isValidStatusCode,
|
||||
failWebsocketConnection,
|
||||
websocketMessageReceived
|
||||
websocketMessageReceived,
|
||||
utf8Decode
|
||||
}
|
||||
+98
-1615
File diff suppressed because it is too large.
Load diff
Vendored
+12
-8
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "undici",
|
||||
"version": "6.11.1",
|
||||
"version": "6.13.0",
|
||||
"description": "An HTTP/1.1 client, written from scratch for Node.js",
|
||||
"homepage": "https://undici.nodejs.org",
|
||||
"bugs": {
|
||||
@@ -68,20 +68,25 @@
|
||||
"lint": "standard | snazzy",
|
||||
"lint:fix": "standard --fix | snazzy",
|
||||
"test": "npm run test:javascript && cross-env NODE_V8_COVERAGE= npm run test:typescript",
|
||||
"test:javascript": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:wpt && npm run test:websocket && npm run test:node-test && npm run test:jest",
|
||||
"test:javascript:withoutintl": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:fetch:nobuild && npm run test:cookies && npm run test:eventsource:nobuild && npm run test:wpt:withoutintl && npm run test:node-test",
|
||||
"test:javascript": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:cache && npm run test:interceptors && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:wpt && npm run test:websocket && npm run test:node-test && npm run test:jest",
|
||||
"test:javascript:withoutintl": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:fetch:nobuild && npm run test:cache && npm run test:interceptors && npm run test:cookies && npm run test:eventsource:nobuild && npm run test:wpt:withoutintl && npm run test:node-test",
|
||||
"test:busboy": "borp -p \"test/busboy/*.js\"",
|
||||
"test:cache": "borp -p \"test/cache/*.js\"",
|
||||
"test:cookies": "borp -p \"test/cookie/*.js\"",
|
||||
"test:node-fetch": "borp -p \"test/node-fetch/**/*.js\"",
|
||||
"test:eventsource": "npm run build:node && npm run test:eventsource:nobuild",
|
||||
"test:eventsource:nobuild": "borp --expose-gc -p \"test/eventsource/*.js\"",
|
||||
"test:fuzzing": "node test/fuzzing/fuzzing.test.js",
|
||||
"test:fetch": "npm run build:node && npm run test:fetch:nobuild",
|
||||
"test:fetch:nobuild": "borp --expose-gc -p \"test/fetch/*.js\" && borp -p \"test/webidl/*.js\" && borp -p \"test/busboy/*.js\"",
|
||||
"test:fetch:nobuild": "borp --expose-gc -p \"test/fetch/*.js\" && npm run test:webidl && npm run test:busboy",
|
||||
"test:interceptors": "borp -p \"test/interceptors/*.js\"",
|
||||
"test:jest": "cross-env NODE_V8_COVERAGE= jest",
|
||||
"test:unit": "borp --expose-gc -p \"test/*.js\"",
|
||||
"test:node-fetch": "borp -p \"test/node-fetch/**/*.js\"",
|
||||
"test:node-test": "borp -p \"test/node-test/**/*.js\"",
|
||||
"test:tdd": "borp --expose-gc -p \"test/*.js\"",
|
||||
"test:tdd:node-test": "borp -p \"test/node-test/**/*.js\" -w",
|
||||
"test:typescript": "tsd && tsc --skipLibCheck test/imports/undici-import.ts",
|
||||
"test:webidl": "borp -p \"test/webidl/*.js\"",
|
||||
"test:websocket": "borp -p \"test/websocket/*.js\"",
|
||||
"test:wpt": "node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-websockets.mjs && node test/wpt/start-cacheStorage.mjs && node test/wpt/start-eventsource.mjs",
|
||||
"test:wpt:withoutintl": "node test/wpt/start-fetch.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-cacheStorage.mjs && node test/wpt/start-eventsource.mjs",
|
||||
@@ -92,8 +97,7 @@
|
||||
"coverage:report:ci": "c8 report",
|
||||
"bench": "echo \"Error: Benchmarks have been moved to '/benchmarks'\" && exit 1",
|
||||
"serve:website": "echo \"Error: Documentation has been moved to '/docs'\" && exit 1",
|
||||
"prepare": "husky install && node ./scripts/platform-shell.js",
|
||||
"fuzz": "jsfuzz test/fuzzing/fuzz.js corpus"
|
||||
"prepare": "husky install && node ./scripts/platform-shell.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@matteo.collina/tspl": "^0.1.1",
|
||||
@@ -104,13 +108,13 @@
|
||||
"c8": "^9.1.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"dns-packet": "^5.4.0",
|
||||
"fast-check": "^3.17.1",
|
||||
"form-data": "^4.0.0",
|
||||
"formdata-node": "^4.3.1",
|
||||
"https-pem": "^3.0.0",
|
||||
"husky": "^9.0.7",
|
||||
"jest": "^29.0.2",
|
||||
"jsdom": "^24.0.0",
|
||||
"jsfuzz": "^1.0.15",
|
||||
"node-forge": "^1.3.1",
|
||||
"pre-commit": "^1.2.2",
|
||||
"proxy": "^2.1.1",
|
||||
|
||||
+1
-1
@@ -225,7 +225,7 @@ declare namespace Dispatcher {
|
||||
/** Invoked when response is received, before headers have been read. **/
|
||||
onResponseStarted?(): void;
|
||||
/** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
|
||||
onHeaders?(statusCode: number, headers: Buffer[] | string[] | null, resume: () => void, statusText: string): boolean;
|
||||
onHeaders?(statusCode: number, headers: Buffer[], resume: () => void, statusText: string): boolean;
|
||||
/** Invoked when response payload data is received. */
|
||||
onData?(chunk: Buffer): boolean;
|
||||
/** Invoked when response payload and trailers have been received and the request has completed. */
|
||||
|
||||
Vendored
+1
-1
@@ -163,7 +163,7 @@ export declare class Request extends BodyMixin {
|
||||
readonly method: string
|
||||
readonly mode: RequestMode
|
||||
readonly redirect: RequestRedirect
|
||||
readonly referrerPolicy: string
|
||||
readonly referrerPolicy: ReferrerPolicy
|
||||
readonly url: string
|
||||
|
||||
readonly keepalive: boolean
|
||||
|
||||
Vendored
+272
-270
@@ -638,7 +638,7 @@ var require_util = __commonJS({
|
||||
"lib/core/util.js"(exports2, module2) {
|
||||
"use strict";
|
||||
var assert = require("node:assert");
|
||||
var { kDestroyed, kBodyUsed } = require_symbols();
|
||||
var { kDestroyed, kBodyUsed, kListeners } = require_symbols();
|
||||
var { IncomingMessage } = require("node:http");
|
||||
var stream = require("node:stream");
|
||||
var net = require("node:net");
|
||||
@@ -657,7 +657,16 @@ var require_util = __commonJS({
|
||||
}
|
||||
__name(isStream, "isStream");
|
||||
function isBlobLike(object) {
|
||||
return Blob2 && object instanceof Blob2 || object && typeof object === "object" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
|
||||
if (object === null) {
|
||||
return false;
|
||||
} else if (object instanceof Blob2) {
|
||||
return true;
|
||||
} else if (typeof object !== "object") {
|
||||
return false;
|
||||
} else {
|
||||
const sTag = object[Symbol.toStringTag];
|
||||
return (sTag === "Blob" || sTag === "File") && ("stream" in object && typeof object.stream === "function" || "arrayBuffer" in object && typeof object.arrayBuffer === "function");
|
||||
}
|
||||
}
|
||||
__name(isBlobLike, "isBlobLike");
|
||||
function buildURL(url, queryParams) {
|
||||
@@ -1035,6 +1044,29 @@ var require_util = __commonJS({
|
||||
} : null;
|
||||
}
|
||||
__name(parseRangeHeader, "parseRangeHeader");
|
||||
function addListener(obj, name, listener) {
|
||||
const listeners = obj[kListeners] ??= [];
|
||||
listeners.push([name, listener]);
|
||||
obj.on(name, listener);
|
||||
return obj;
|
||||
}
|
||||
__name(addListener, "addListener");
|
||||
function removeAllListeners(obj) {
|
||||
for (const [name, listener] of obj[kListeners] ?? []) {
|
||||
obj.removeListener(name, listener);
|
||||
}
|
||||
obj[kListeners] = null;
|
||||
}
|
||||
__name(removeAllListeners, "removeAllListeners");
|
||||
function errorRequest(client, request, err) {
|
||||
try {
|
||||
request.onError(err);
|
||||
assert(request.aborted);
|
||||
} catch (err2) {
|
||||
client.emit("error", err2);
|
||||
}
|
||||
}
|
||||
__name(errorRequest, "errorRequest");
|
||||
var kEnumerableProperty = /* @__PURE__ */ Object.create(null);
|
||||
kEnumerableProperty.enumerable = true;
|
||||
module2.exports = {
|
||||
@@ -1056,6 +1088,9 @@ var require_util = __commonJS({
|
||||
isDestroyed,
|
||||
headerNameToString,
|
||||
bufferToLowerCasedHeaderName,
|
||||
addListener,
|
||||
removeAllListeners,
|
||||
errorRequest,
|
||||
parseRawHeaders,
|
||||
parseHeaders,
|
||||
parseKeepAliveTimeout,
|
||||
@@ -1160,6 +1195,7 @@ var require_constants2 = __commonJS({
|
||||
"2049",
|
||||
"3659",
|
||||
"4045",
|
||||
"4190",
|
||||
"5060",
|
||||
"5061",
|
||||
"6000",
|
||||
@@ -1169,6 +1205,7 @@ var require_constants2 = __commonJS({
|
||||
"6667",
|
||||
"6668",
|
||||
"6669",
|
||||
"6679",
|
||||
"6697",
|
||||
"10080"
|
||||
];
|
||||
@@ -2115,12 +2152,10 @@ var require_util2 = __commonJS({
|
||||
}
|
||||
__name(responseLocationURL, "responseLocationURL");
|
||||
function isValidEncodedURL(url) {
|
||||
for (const c of url) {
|
||||
const code = c.charCodeAt(0);
|
||||
if (code >= 128) {
|
||||
return false;
|
||||
}
|
||||
if (code >= 0 && code <= 31 || code === 127) {
|
||||
for (let i = 0; i < url.length; ++i) {
|
||||
const code = url.charCodeAt(i);
|
||||
if (code > 126 || // Non-US-ASCII + DEL
|
||||
code < 32) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2161,13 +2196,7 @@ var require_util2 = __commonJS({
|
||||
__name(isValidReasonPhrase, "isValidReasonPhrase");
|
||||
var isValidHeaderName = isValidHTTPToken;
|
||||
function isValidHeaderValue(potentialValue) {
|
||||
if (potentialValue.startsWith(" ") || potentialValue.startsWith(" ") || potentialValue.endsWith(" ") || potentialValue.endsWith(" ")) {
|
||||
return false;
|
||||
}
|
||||
if (potentialValue.includes("\0") || potentialValue.includes("\r") || potentialValue.includes("\n")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return (potentialValue[0] === " " || potentialValue[0] === " " || potentialValue[potentialValue.length - 1] === " " || potentialValue[potentialValue.length - 1] === " " || potentialValue.includes("\n") || potentialValue.includes("\r") || potentialValue.includes("\0")) === false;
|
||||
}
|
||||
__name(isValidHeaderValue, "isValidHeaderValue");
|
||||
function setRequestReferrerPolicyOnRedirect(request, actualResponse) {
|
||||
@@ -2743,10 +2772,7 @@ var require_util2 = __commonJS({
|
||||
}
|
||||
__name(urlIsLocal, "urlIsLocal");
|
||||
function urlHasHttpsScheme(url) {
|
||||
if (typeof url === "string") {
|
||||
return url.startsWith("https:");
|
||||
}
|
||||
return url.protocol === "https:";
|
||||
return typeof url === "string" && url[5] === ":" && url[0] === "h" && url[1] === "t" && url[2] === "t" && url[3] === "p" && url[4] === "s" || url.protocol === "https:";
|
||||
}
|
||||
__name(urlHasHttpsScheme, "urlHasHttpsScheme");
|
||||
function urlIsHttpHttpsScheme(url) {
|
||||
@@ -2951,6 +2977,7 @@ var require_util2 = __commonJS({
|
||||
module2.exports = {
|
||||
isAborted,
|
||||
isCancelled,
|
||||
isValidEncodedURL,
|
||||
createDeferredPromise,
|
||||
ReadableStreamFrom,
|
||||
tryUpgradeRequestToAPotentiallyTrustworthyURL,
|
||||
@@ -3752,7 +3779,7 @@ var require_formdata = __commonJS({
|
||||
var require_formdata_parser = __commonJS({
|
||||
"lib/web/fetch/formdata-parser.js"(exports2, module2) {
|
||||
"use strict";
|
||||
var { toUSVString, isUSVString, bufferToLowerCasedHeaderName } = require_util();
|
||||
var { isUSVString, bufferToLowerCasedHeaderName } = require_util();
|
||||
var { utf8DecodeBytes } = require_util2();
|
||||
var { HTTP_TOKEN_CODEPOINTS, isomorphicDecode } = require_data_url();
|
||||
var { isFileLike, File: UndiciFile } = require_file();
|
||||
@@ -3787,18 +3814,6 @@ var require_formdata_parser = __commonJS({
|
||||
return true;
|
||||
}
|
||||
__name(validateBoundary, "validateBoundary");
|
||||
function escapeFormDataName(name, encoding = "utf-8", isFilename = false) {
|
||||
if (isFilename) {
|
||||
name = toUSVString(name);
|
||||
} else {
|
||||
assert(isUSVString(name));
|
||||
name = name.replace(/\r\n?|\r?\n/g, "\r\n");
|
||||
}
|
||||
assert(Buffer.isEncoding(encoding));
|
||||
name = name.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
|
||||
return Buffer.from(name, encoding);
|
||||
}
|
||||
__name(escapeFormDataName, "escapeFormDataName");
|
||||
function multipartFormDataParser(input, mimeType) {
|
||||
assert(mimeType !== "failure" && mimeType.essence === "multipart/form-data");
|
||||
const boundaryString = mimeType.parameters.get("boundary");
|
||||
@@ -4009,8 +4024,7 @@ var require_formdata_parser = __commonJS({
|
||||
__name(bufferStartsWith, "bufferStartsWith");
|
||||
module2.exports = {
|
||||
multipartFormDataParser,
|
||||
validateBoundary,
|
||||
escapeFormDataName
|
||||
validateBoundary
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -4263,10 +4277,10 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
||||
__name(mixinBody, "mixinBody");
|
||||
async function consumeBody(object, convertBytesToJSValue, instance) {
|
||||
webidl.brandCheck(object, instance);
|
||||
throwIfAborted(object[kState]);
|
||||
if (bodyUnusable(object[kState].body)) {
|
||||
throw new TypeError("Body is unusable");
|
||||
}
|
||||
throwIfAborted(object[kState]);
|
||||
const promise = createDeferredPromise();
|
||||
const errorSteps = /* @__PURE__ */ __name((error) => promise.reject(error), "errorSteps");
|
||||
const successSteps = /* @__PURE__ */ __name((data) => {
|
||||
@@ -7119,7 +7133,6 @@ var require_client_h1 = __commonJS({
|
||||
kMaxRequests,
|
||||
kCounter,
|
||||
kMaxResponseSize,
|
||||
kListeners,
|
||||
kOnError,
|
||||
kResume,
|
||||
kHTTPContext
|
||||
@@ -7127,21 +7140,9 @@ var require_client_h1 = __commonJS({
|
||||
var constants = require_constants3();
|
||||
var EMPTY_BUF = Buffer.alloc(0);
|
||||
var FastBuffer = Buffer[Symbol.species];
|
||||
var addListener = util.addListener;
|
||||
var removeAllListeners = util.removeAllListeners;
|
||||
var extractBody;
|
||||
function addListener(obj, name, listener) {
|
||||
const listeners = obj[kListeners] ??= [];
|
||||
listeners.push([name, listener]);
|
||||
obj.on(name, listener);
|
||||
return obj;
|
||||
}
|
||||
__name(addListener, "addListener");
|
||||
function removeAllListeners(obj) {
|
||||
for (const [name, listener] of obj[kListeners] ?? []) {
|
||||
obj.removeListener(name, listener);
|
||||
}
|
||||
obj[kListeners] = null;
|
||||
}
|
||||
__name(removeAllListeners, "removeAllListeners");
|
||||
async function lazyllhttp() {
|
||||
const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
|
||||
let mod;
|
||||
@@ -7630,12 +7631,12 @@ var require_client_h1 = __commonJS({
|
||||
const requests = client2[kQueue].splice(client2[kRunningIdx]);
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i];
|
||||
errorRequest(client2, request, err);
|
||||
util.errorRequest(client2, request, err);
|
||||
}
|
||||
} else if (client2[kRunning] > 0 && err.code !== "UND_ERR_INFO") {
|
||||
const request = client2[kQueue][client2[kRunningIdx]];
|
||||
client2[kQueue][client2[kRunningIdx]++] = null;
|
||||
errorRequest(client2, request, err);
|
||||
util.errorRequest(client2, request, err);
|
||||
}
|
||||
client2[kPendingIdx] = client2[kRunningIdx];
|
||||
assert(client2[kRunning] === 0);
|
||||
@@ -7711,15 +7712,6 @@ var require_client_h1 = __commonJS({
|
||||
}
|
||||
}
|
||||
__name(resumeH1, "resumeH1");
|
||||
function errorRequest(client, request, err) {
|
||||
try {
|
||||
request.onError(err);
|
||||
assert(request.aborted);
|
||||
} catch (err2) {
|
||||
client.emit("error", err2);
|
||||
}
|
||||
}
|
||||
__name(errorRequest, "errorRequest");
|
||||
function shouldSendContentLength(method) {
|
||||
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
||||
}
|
||||
@@ -7754,25 +7746,26 @@ var require_client_h1 = __commonJS({
|
||||
}
|
||||
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
|
||||
if (client[kStrictContentLength]) {
|
||||
errorRequest(client, request, new RequestContentLengthMismatchError());
|
||||
util.errorRequest(client, request, new RequestContentLengthMismatchError());
|
||||
return false;
|
||||
}
|
||||
process.emitWarning(new RequestContentLengthMismatchError());
|
||||
}
|
||||
const socket = client[kSocket];
|
||||
const abort = /* @__PURE__ */ __name((err) => {
|
||||
if (request.aborted || request.completed) {
|
||||
return;
|
||||
}
|
||||
util.errorRequest(client, request, err || new RequestAbortedError());
|
||||
util.destroy(body);
|
||||
util.destroy(socket, new InformationalError("aborted"));
|
||||
}, "abort");
|
||||
try {
|
||||
request.onConnect((err) => {
|
||||
if (request.aborted || request.completed) {
|
||||
return;
|
||||
}
|
||||
errorRequest(client, request, err || new RequestAbortedError());
|
||||
util.destroy(socket, new InformationalError("aborted"));
|
||||
});
|
||||
request.onConnect(abort);
|
||||
} catch (err) {
|
||||
errorRequest(client, request, err);
|
||||
util.errorRequest(client, request, err);
|
||||
}
|
||||
if (request.aborted) {
|
||||
util.destroy(body);
|
||||
return false;
|
||||
}
|
||||
if (method === "HEAD") {
|
||||
@@ -7826,49 +7819,29 @@ upgrade: ${upgrade}\r
|
||||
channels.sendHeaders.publish({ request, headers: header, socket });
|
||||
}
|
||||
if (!body || bodyLength === 0) {
|
||||
if (contentLength === 0) {
|
||||
socket.write(`${header}content-length: 0\r
|
||||
\r
|
||||
`, "latin1");
|
||||
} else {
|
||||
assert(contentLength === null, "no body must not have content length");
|
||||
socket.write(`${header}\r
|
||||
`, "latin1");
|
||||
}
|
||||
request.onRequestSent();
|
||||
writeBuffer({ abort, body: null, client, request, socket, contentLength, header, expectsPayload });
|
||||
} else if (util.isBuffer(body)) {
|
||||
assert(contentLength === body.byteLength, "buffer body must have content length");
|
||||
socket.cork();
|
||||
socket.write(`${header}content-length: ${contentLength}\r
|
||||
\r
|
||||
`, "latin1");
|
||||
socket.write(body);
|
||||
socket.uncork();
|
||||
request.onBodySent(body);
|
||||
request.onRequestSent();
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true;
|
||||
}
|
||||
writeBuffer({ abort, body, client, request, socket, contentLength, header, expectsPayload });
|
||||
} else if (util.isBlobLike(body)) {
|
||||
if (typeof body.stream === "function") {
|
||||
writeIterable({ body: body.stream(), client, request, socket, contentLength, header, expectsPayload });
|
||||
writeIterable({ abort, body: body.stream(), client, request, socket, contentLength, header, expectsPayload });
|
||||
} else {
|
||||
writeBlob({ body, client, request, socket, contentLength, header, expectsPayload });
|
||||
writeBlob({ abort, body, client, request, socket, contentLength, header, expectsPayload });
|
||||
}
|
||||
} else if (util.isStream(body)) {
|
||||
writeStream({ body, client, request, socket, contentLength, header, expectsPayload });
|
||||
writeStream({ abort, body, client, request, socket, contentLength, header, expectsPayload });
|
||||
} else if (util.isIterable(body)) {
|
||||
writeIterable({ body, client, request, socket, contentLength, header, expectsPayload });
|
||||
writeIterable({ abort, body, client, request, socket, contentLength, header, expectsPayload });
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
__name(writeH1, "writeH1");
|
||||
function writeStream({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
function writeStream({ abort, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined");
|
||||
let finished = false;
|
||||
const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header });
|
||||
const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header });
|
||||
const onData = /* @__PURE__ */ __name(function(chunk) {
|
||||
if (finished) {
|
||||
return;
|
||||
@@ -7935,7 +7908,39 @@ upgrade: ${upgrade}\r
|
||||
}
|
||||
}
|
||||
__name(writeStream, "writeStream");
|
||||
async function writeBlob({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
async function writeBuffer({ abort, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
try {
|
||||
if (!body) {
|
||||
if (contentLength === 0) {
|
||||
socket.write(`${header}content-length: 0\r
|
||||
\r
|
||||
`, "latin1");
|
||||
} else {
|
||||
assert(contentLength === null, "no body must not have content length");
|
||||
socket.write(`${header}\r
|
||||
`, "latin1");
|
||||
}
|
||||
} else if (util.isBuffer(body)) {
|
||||
assert(contentLength === body.byteLength, "buffer body must have content length");
|
||||
socket.cork();
|
||||
socket.write(`${header}content-length: ${contentLength}\r
|
||||
\r
|
||||
`, "latin1");
|
||||
socket.write(body);
|
||||
socket.uncork();
|
||||
request.onBodySent(body);
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true;
|
||||
}
|
||||
}
|
||||
request.onRequestSent();
|
||||
client[kResume]();
|
||||
} catch (err) {
|
||||
abort(err);
|
||||
}
|
||||
}
|
||||
__name(writeBuffer, "writeBuffer");
|
||||
async function writeBlob({ abort, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
assert(contentLength === body.size, "blob body must have content length");
|
||||
try {
|
||||
if (contentLength != null && contentLength !== body.size) {
|
||||
@@ -7955,11 +7960,11 @@ upgrade: ${upgrade}\r
|
||||
}
|
||||
client[kResume]();
|
||||
} catch (err) {
|
||||
util.destroy(socket, err);
|
||||
abort(err);
|
||||
}
|
||||
}
|
||||
__name(writeBlob, "writeBlob");
|
||||
async function writeIterable({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
async function writeIterable({ abort, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined");
|
||||
let callback = null;
|
||||
function onDrain() {
|
||||
@@ -7979,7 +7984,7 @@ upgrade: ${upgrade}\r
|
||||
}
|
||||
}), "waitForDrain");
|
||||
socket.on("close", onDrain).on("drain", onDrain);
|
||||
const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header });
|
||||
const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header });
|
||||
try {
|
||||
for await (const chunk of body) {
|
||||
if (socket[kError]) {
|
||||
@@ -8001,7 +8006,7 @@ upgrade: ${upgrade}\r
|
||||
static {
|
||||
__name(this, "AsyncWriter");
|
||||
}
|
||||
constructor({ socket, request, contentLength, client, expectsPayload, header }) {
|
||||
constructor({ abort, socket, request, contentLength, client, expectsPayload, header }) {
|
||||
this.socket = socket;
|
||||
this.request = request;
|
||||
this.contentLength = contentLength;
|
||||
@@ -8009,6 +8014,7 @@ upgrade: ${upgrade}\r
|
||||
this.bytesWritten = 0;
|
||||
this.expectsPayload = expectsPayload;
|
||||
this.header = header;
|
||||
this.abort = abort;
|
||||
socket[kWriting] = true;
|
||||
}
|
||||
write(chunk) {
|
||||
@@ -8098,11 +8104,11 @@ ${len.toString(16)}\r
|
||||
client[kResume]();
|
||||
}
|
||||
destroy(err) {
|
||||
const { socket, client } = this;
|
||||
const { socket, client, abort } = this;
|
||||
socket[kWriting] = false;
|
||||
if (err) {
|
||||
assert(client[kRunning] <= 1, "pipeline should only contain this request");
|
||||
util.destroy(socket, err);
|
||||
abort(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -8136,7 +8142,6 @@ var require_client_h2 = __commonJS({
|
||||
kSocket,
|
||||
kStrictContentLength,
|
||||
kOnError,
|
||||
// HTTP2
|
||||
kMaxConcurrentStreams,
|
||||
kHTTP2Session,
|
||||
kResume
|
||||
@@ -8161,10 +8166,15 @@ var require_client_h2 = __commonJS({
|
||||
}
|
||||
} = http2;
|
||||
function parseH2Headers(headers) {
|
||||
headers = Object.entries(headers).flat(2);
|
||||
const result = [];
|
||||
for (const header of headers) {
|
||||
result.push(Buffer.from(header));
|
||||
for (const [name, value] of Object.entries(headers)) {
|
||||
if (Array.isArray(value)) {
|
||||
for (const subvalue of value) {
|
||||
result.push(Buffer.from(name), Buffer.from(subvalue));
|
||||
}
|
||||
} else {
|
||||
result.push(Buffer.from(name), Buffer.from(value));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -8184,36 +8194,46 @@ var require_client_h2 = __commonJS({
|
||||
session[kOpenStreams] = 0;
|
||||
session[kClient] = client;
|
||||
session[kSocket] = socket;
|
||||
session.on("error", onHttp2SessionError);
|
||||
session.on("frameError", onHttp2FrameError);
|
||||
session.on("end", onHttp2SessionEnd);
|
||||
session.on("goaway", onHTTP2GoAway);
|
||||
session.on("close", function() {
|
||||
util.addListener(session, "error", onHttp2SessionError);
|
||||
util.addListener(session, "frameError", onHttp2FrameError);
|
||||
util.addListener(session, "end", onHttp2SessionEnd);
|
||||
util.addListener(session, "goaway", onHTTP2GoAway);
|
||||
util.addListener(session, "close", function() {
|
||||
const { [kClient]: client2 } = this;
|
||||
const err = this[kError] || new SocketError("closed", util.getSocketInfo(this));
|
||||
client2[kSocket] = null;
|
||||
assert(client2[kPending] === 0);
|
||||
const requests = client2[kQueue].splice(client2[kRunningIdx]);
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i];
|
||||
errorRequest(client2, request, err);
|
||||
const { [kSocket]: socket2 } = client2;
|
||||
const err = this[kSocket][kError] || this[kError] || new SocketError("closed", util.getSocketInfo(socket2));
|
||||
client2[kHTTP2Session] = null;
|
||||
if (client2.destroyed) {
|
||||
assert(client2[kPending] === 0);
|
||||
const requests = client2[kQueue].splice(client2[kRunningIdx]);
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i];
|
||||
util.errorRequest(client2, request, err);
|
||||
}
|
||||
}
|
||||
client2[kPendingIdx] = client2[kRunningIdx];
|
||||
assert(client2[kRunning] === 0);
|
||||
client2.emit("disconnect", client2[kUrl], [client2], err);
|
||||
client2[kResume]();
|
||||
});
|
||||
session.unref();
|
||||
client[kHTTP2Session] = session;
|
||||
socket[kHTTP2Session] = session;
|
||||
socket.on("error", function(err) {
|
||||
util.addListener(socket, "error", function(err) {
|
||||
assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
|
||||
this[kError] = err;
|
||||
this[kClient][kOnError](err);
|
||||
});
|
||||
socket.on("end", function() {
|
||||
util.addListener(socket, "end", function() {
|
||||
util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this)));
|
||||
});
|
||||
util.addListener(socket, "close", function() {
|
||||
const err = this[kError] || new SocketError("closed", util.getSocketInfo(this));
|
||||
client[kSocket] = null;
|
||||
if (this[kHTTP2Session] != null) {
|
||||
this[kHTTP2Session].destroy(err);
|
||||
}
|
||||
client[kPendingIdx] = client[kRunningIdx];
|
||||
assert(client[kRunning] === 0);
|
||||
client.emit("disconnect", client[kUrl], [client], err);
|
||||
client[kResume]();
|
||||
});
|
||||
let closed = false;
|
||||
socket.on("close", () => {
|
||||
closed = true;
|
||||
@@ -8227,7 +8247,6 @@ var require_client_h2 = __commonJS({
|
||||
resume() {
|
||||
},
|
||||
destroy(err, callback) {
|
||||
session.destroy(err);
|
||||
if (closed) {
|
||||
queueMicrotask(callback);
|
||||
} else {
|
||||
@@ -8250,55 +8269,28 @@ var require_client_h2 = __commonJS({
|
||||
}
|
||||
__name(onHttp2SessionError, "onHttp2SessionError");
|
||||
function onHttp2FrameError(type, code, id) {
|
||||
const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`);
|
||||
if (id === 0) {
|
||||
const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`);
|
||||
this[kSocket][kError] = err;
|
||||
this[kClient][kOnError](err);
|
||||
}
|
||||
}
|
||||
__name(onHttp2FrameError, "onHttp2FrameError");
|
||||
function onHttp2SessionEnd() {
|
||||
this.destroy(new SocketError("other side closed"));
|
||||
util.destroy(this[kSocket], new SocketError("other side closed"));
|
||||
const err = new SocketError("other side closed", util.getSocketInfo(this[kSocket]));
|
||||
this.destroy(err);
|
||||
util.destroy(this[kSocket], err);
|
||||
}
|
||||
__name(onHttp2SessionEnd, "onHttp2SessionEnd");
|
||||
function onHTTP2GoAway(code) {
|
||||
const client = this[kClient];
|
||||
const err = new InformationalError(`HTTP/2: "GOAWAY" frame received with code ${code}`);
|
||||
client[kSocket] = null;
|
||||
client[kHTTP2Session] = null;
|
||||
if (client.destroyed) {
|
||||
assert(this[kPending] === 0);
|
||||
const requests = client[kQueue].splice(client[kRunningIdx]);
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i];
|
||||
errorRequest(this, request, err);
|
||||
}
|
||||
} else if (client[kRunning] > 0) {
|
||||
const request = client[kQueue][client[kRunningIdx]];
|
||||
client[kQueue][client[kRunningIdx]++] = null;
|
||||
errorRequest(client, request, err);
|
||||
}
|
||||
client[kPendingIdx] = client[kRunningIdx];
|
||||
assert(client[kRunning] === 0);
|
||||
client.emit(
|
||||
"disconnect",
|
||||
client[kUrl],
|
||||
[client],
|
||||
err
|
||||
);
|
||||
client[kResume]();
|
||||
this[kSocket][kError] = err;
|
||||
this[kClient][kOnError](err);
|
||||
this.unref();
|
||||
this.destroy();
|
||||
util.destroy(this[kSocket], err);
|
||||
}
|
||||
__name(onHTTP2GoAway, "onHTTP2GoAway");
|
||||
function errorRequest(client, request, err) {
|
||||
try {
|
||||
request.onError(err);
|
||||
assert(request.aborted);
|
||||
} catch (err2) {
|
||||
client.emit("error", err2);
|
||||
}
|
||||
}
|
||||
__name(errorRequest, "errorRequest");
|
||||
function shouldSendContentLength(method) {
|
||||
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
||||
}
|
||||
@@ -8307,7 +8299,7 @@ var require_client_h2 = __commonJS({
|
||||
const session = client[kHTTP2Session];
|
||||
const { body, method, path, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
|
||||
if (upgrade) {
|
||||
errorRequest(client, request, new Error("Upgrade not supported for H2"));
|
||||
util.errorRequest(client, request, new Error("Upgrade not supported for H2"));
|
||||
return false;
|
||||
}
|
||||
if (request.aborted) {
|
||||
@@ -8333,23 +8325,21 @@ var require_client_h2 = __commonJS({
|
||||
const { hostname, port } = client[kUrl];
|
||||
headers[HTTP2_HEADER_AUTHORITY] = host || `${hostname}${port ? `:${port}` : ""}`;
|
||||
headers[HTTP2_HEADER_METHOD] = method;
|
||||
const abort = /* @__PURE__ */ __name((err) => {
|
||||
if (request.aborted || request.completed) {
|
||||
return;
|
||||
}
|
||||
err = err || new RequestAbortedError();
|
||||
util.errorRequest(client, request, err);
|
||||
if (stream != null) {
|
||||
util.destroy(stream, err);
|
||||
}
|
||||
util.destroy(body, err);
|
||||
}, "abort");
|
||||
try {
|
||||
request.onConnect((err) => {
|
||||
if (request.aborted || request.completed) {
|
||||
return;
|
||||
}
|
||||
err = err || new RequestAbortedError();
|
||||
if (stream != null) {
|
||||
util.destroy(stream, err);
|
||||
session[kOpenStreams] -= 1;
|
||||
if (session[kOpenStreams] === 0) {
|
||||
session.unref();
|
||||
}
|
||||
}
|
||||
errorRequest(client, request, err);
|
||||
});
|
||||
request.onConnect(abort);
|
||||
} catch (err) {
|
||||
errorRequest(client, request, err);
|
||||
util.errorRequest(client, request, err);
|
||||
}
|
||||
if (method === "CONNECT") {
|
||||
session.ref();
|
||||
@@ -8385,7 +8375,7 @@ var require_client_h2 = __commonJS({
|
||||
}
|
||||
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength != null && request.contentLength !== contentLength) {
|
||||
if (client[kStrictContentLength]) {
|
||||
errorRequest(client, request, new RequestContentLengthMismatchError());
|
||||
util.errorRequest(client, request, new RequestContentLengthMismatchError());
|
||||
return false;
|
||||
}
|
||||
process.emitWarning(new RequestContentLengthMismatchError());
|
||||
@@ -8411,9 +8401,9 @@ var require_client_h2 = __commonJS({
|
||||
stream.once("response", (headers2) => {
|
||||
const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers2;
|
||||
request.onResponseStarted();
|
||||
if (request.aborted || request.completed) {
|
||||
if (request.aborted) {
|
||||
const err = new RequestAbortedError();
|
||||
errorRequest(client, request, err);
|
||||
util.errorRequest(client, request, err);
|
||||
util.destroy(stream, err);
|
||||
return;
|
||||
}
|
||||
@@ -8431,13 +8421,10 @@ var require_client_h2 = __commonJS({
|
||||
request.onComplete([]);
|
||||
return;
|
||||
}
|
||||
session[kOpenStreams] -= 1;
|
||||
if (session[kOpenStreams] === 0) {
|
||||
session.unref();
|
||||
}
|
||||
const err = new InformationalError("HTTP/2: stream half-closed (remote)");
|
||||
errorRequest(client, request, err);
|
||||
util.destroy(stream, err);
|
||||
abort(new InformationalError("HTTP/2: stream half-closed (remote)"));
|
||||
});
|
||||
stream.once("close", () => {
|
||||
session[kOpenStreams] -= 1;
|
||||
@@ -8446,52 +8433,56 @@ var require_client_h2 = __commonJS({
|
||||
}
|
||||
});
|
||||
stream.once("error", function(err) {
|
||||
if (client[kHTTP2Session] && !client[kHTTP2Session].destroyed && !this.closed && !this.destroyed) {
|
||||
session[kOpenStreams] -= 1;
|
||||
util.destroy(stream, err);
|
||||
}
|
||||
abort(err);
|
||||
});
|
||||
stream.once("frameError", (type, code) => {
|
||||
const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`);
|
||||
errorRequest(client, request, err);
|
||||
if (client[kHTTP2Session] && !client[kHTTP2Session].destroyed && !this.closed && !this.destroyed) {
|
||||
session[kOpenStreams] -= 1;
|
||||
util.destroy(stream, err);
|
||||
}
|
||||
abort(new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`));
|
||||
});
|
||||
return true;
|
||||
function writeBodyH2() {
|
||||
if (!body) {
|
||||
request.onRequestSent();
|
||||
if (!body || contentLength === 0) {
|
||||
writeBuffer({
|
||||
abort,
|
||||
client,
|
||||
request,
|
||||
contentLength,
|
||||
expectsPayload,
|
||||
h2stream: stream,
|
||||
body: null,
|
||||
socket: client[kSocket]
|
||||
});
|
||||
} else if (util.isBuffer(body)) {
|
||||
assert(contentLength === body.byteLength, "buffer body must have content length");
|
||||
stream.cork();
|
||||
stream.write(body);
|
||||
stream.uncork();
|
||||
stream.end();
|
||||
request.onBodySent(body);
|
||||
request.onRequestSent();
|
||||
writeBuffer({
|
||||
abort,
|
||||
client,
|
||||
request,
|
||||
contentLength,
|
||||
body,
|
||||
expectsPayload,
|
||||
h2stream: stream,
|
||||
socket: client[kSocket]
|
||||
});
|
||||
} else if (util.isBlobLike(body)) {
|
||||
if (typeof body.stream === "function") {
|
||||
writeIterable({
|
||||
abort,
|
||||
client,
|
||||
request,
|
||||
contentLength,
|
||||
h2stream: stream,
|
||||
expectsPayload,
|
||||
h2stream: stream,
|
||||
body: body.stream(),
|
||||
socket: client[kSocket],
|
||||
header: ""
|
||||
socket: client[kSocket]
|
||||
});
|
||||
} else {
|
||||
writeBlob({
|
||||
abort,
|
||||
body,
|
||||
client,
|
||||
request,
|
||||
contentLength,
|
||||
expectsPayload,
|
||||
h2stream: stream,
|
||||
header: "",
|
||||
socket: client[kSocket]
|
||||
});
|
||||
}
|
||||
@@ -8524,32 +8515,53 @@ var require_client_h2 = __commonJS({
|
||||
__name(writeBodyH2, "writeBodyH2");
|
||||
}
|
||||
__name(writeH2, "writeH2");
|
||||
function writeStream({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
function writeBuffer({ abort, h2stream, body, client, request, socket, contentLength, expectsPayload }) {
|
||||
try {
|
||||
if (body != null && util.isBuffer(body)) {
|
||||
assert(contentLength === body.byteLength, "buffer body must have content length");
|
||||
h2stream.cork();
|
||||
h2stream.write(body);
|
||||
h2stream.uncork();
|
||||
h2stream.end();
|
||||
request.onBodySent(body);
|
||||
}
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true;
|
||||
}
|
||||
request.onRequestSent();
|
||||
client[kResume]();
|
||||
} catch (error) {
|
||||
abort(error);
|
||||
}
|
||||
}
|
||||
__name(writeBuffer, "writeBuffer");
|
||||
function writeStream({ abort, socket, expectsPayload, h2stream, body, client, request, contentLength }) {
|
||||
assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined");
|
||||
const pipe = pipeline(
|
||||
body,
|
||||
h2stream,
|
||||
(err) => {
|
||||
if (err) {
|
||||
util.destroy(body, err);
|
||||
util.destroy(h2stream, err);
|
||||
util.destroy(pipe, err);
|
||||
abort(err);
|
||||
} else {
|
||||
util.removeAllListeners(pipe);
|
||||
request.onRequestSent();
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true;
|
||||
}
|
||||
client[kResume]();
|
||||
}
|
||||
}
|
||||
);
|
||||
pipe.on("data", onPipeData);
|
||||
pipe.once("end", () => {
|
||||
pipe.removeListener("data", onPipeData);
|
||||
util.destroy(pipe);
|
||||
});
|
||||
util.addListener(pipe, "data", onPipeData);
|
||||
function onPipeData(chunk) {
|
||||
request.onBodySent(chunk);
|
||||
}
|
||||
__name(onPipeData, "onPipeData");
|
||||
}
|
||||
__name(writeStream, "writeStream");
|
||||
async function writeBlob({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
async function writeBlob({ abort, h2stream, body, client, request, socket, contentLength, expectsPayload }) {
|
||||
assert(contentLength === body.size, "blob body must have content length");
|
||||
try {
|
||||
if (contentLength != null && contentLength !== body.size) {
|
||||
@@ -8559,6 +8571,7 @@ var require_client_h2 = __commonJS({
|
||||
h2stream.cork();
|
||||
h2stream.write(buffer);
|
||||
h2stream.uncork();
|
||||
h2stream.end();
|
||||
request.onBodySent(buffer);
|
||||
request.onRequestSent();
|
||||
if (!expectsPayload) {
|
||||
@@ -8566,11 +8579,11 @@ var require_client_h2 = __commonJS({
|
||||
}
|
||||
client[kResume]();
|
||||
} catch (err) {
|
||||
util.destroy(h2stream);
|
||||
abort(err);
|
||||
}
|
||||
}
|
||||
__name(writeBlob, "writeBlob");
|
||||
async function writeIterable({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
|
||||
async function writeIterable({ abort, h2stream, body, client, request, socket, contentLength, expectsPayload }) {
|
||||
assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined");
|
||||
let callback = null;
|
||||
function onDrain() {
|
||||
@@ -8601,11 +8614,15 @@ var require_client_h2 = __commonJS({
|
||||
await waitForDrain();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
h2stream.destroy(err);
|
||||
} finally {
|
||||
request.onRequestSent();
|
||||
h2stream.end();
|
||||
request.onRequestSent();
|
||||
if (!expectsPayload) {
|
||||
socket[kReset] = true;
|
||||
}
|
||||
client[kResume]();
|
||||
} catch (err) {
|
||||
abort(err);
|
||||
} finally {
|
||||
h2stream.off("close", onDrain).off("drain", onDrain);
|
||||
}
|
||||
}
|
||||
@@ -9085,7 +9102,7 @@ var require_client = __commonJS({
|
||||
const requests = this[kQueue].splice(this[kPendingIdx]);
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i];
|
||||
errorRequest(this, request, err);
|
||||
util.errorRequest(this, request, err);
|
||||
}
|
||||
const callback = /* @__PURE__ */ __name(() => {
|
||||
if (this[kClosedResolve]) {
|
||||
@@ -9111,7 +9128,7 @@ var require_client = __commonJS({
|
||||
const requests = client[kQueue].splice(client[kRunningIdx]);
|
||||
for (let i = 0; i < requests.length; i++) {
|
||||
const request = requests[i];
|
||||
errorRequest(client, request, err);
|
||||
util.errorRequest(client, request, err);
|
||||
}
|
||||
assert(client[kSize] === 0);
|
||||
}
|
||||
@@ -9218,7 +9235,7 @@ var require_client = __commonJS({
|
||||
assert(client[kRunning] === 0);
|
||||
while (client[kPending] > 0 && client[kQueue][client[kPendingIdx]].servername === client[kServerName]) {
|
||||
const request = client[kQueue][client[kPendingIdx]++];
|
||||
errorRequest(client, request, err);
|
||||
util.errorRequest(client, request, err);
|
||||
}
|
||||
} else {
|
||||
onError(client, err);
|
||||
@@ -9284,7 +9301,10 @@ var require_client = __commonJS({
|
||||
return;
|
||||
}
|
||||
client[kServerName] = request.servername;
|
||||
client[kHTTPContext]?.destroy(new InformationalError("servername changed"));
|
||||
client[kHTTPContext]?.destroy(new InformationalError("servername changed"), () => {
|
||||
client[kHTTPContext] = null;
|
||||
resume(client);
|
||||
});
|
||||
}
|
||||
if (client[kConnecting]) {
|
||||
return;
|
||||
@@ -9307,15 +9327,6 @@ var require_client = __commonJS({
|
||||
}
|
||||
}
|
||||
__name(_resume, "_resume");
|
||||
function errorRequest(client, request, err) {
|
||||
try {
|
||||
request.onError(err);
|
||||
assert(request.aborted);
|
||||
} catch (err2) {
|
||||
client.emit("error", err2);
|
||||
}
|
||||
}
|
||||
__name(errorRequest, "errorRequest");
|
||||
module2.exports = Client;
|
||||
}
|
||||
});
|
||||
@@ -9601,7 +9612,7 @@ var require_fetch = __commonJS({
|
||||
subresourceSet
|
||||
} = require_constants2();
|
||||
var EE = require("node:events");
|
||||
var { Readable, pipeline } = require("node:stream");
|
||||
var { Readable, pipeline, finished } = require("node:stream");
|
||||
var { addAbortListener, isErrored, isReadable, nodeMajor, nodeMinor, bufferToLowerCasedHeaderName } = require_util();
|
||||
var { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require_data_url();
|
||||
var { getGlobalDispatcher } = require_global2();
|
||||
@@ -10072,33 +10083,9 @@ var require_fetch = __commonJS({
|
||||
if (internalResponse.body == null) {
|
||||
processResponseEndOfBody();
|
||||
} else {
|
||||
const transformStream = new TransformStream({
|
||||
start() {
|
||||
},
|
||||
transform(chunk, controller) {
|
||||
controller.enqueue(chunk);
|
||||
},
|
||||
flush: processResponseEndOfBody
|
||||
finished(internalResponse.body.stream, () => {
|
||||
processResponseEndOfBody();
|
||||
});
|
||||
internalResponse.body.stream.pipeThrough(transformStream);
|
||||
const byteStream = new ReadableStream({
|
||||
readableStream: transformStream.readable,
|
||||
async start() {
|
||||
this._bodyReader = this.readableStream.getReader();
|
||||
},
|
||||
async pull(controller) {
|
||||
while (controller.desiredSize >= 0) {
|
||||
const { done, value } = await this._bodyReader.read();
|
||||
if (done) {
|
||||
queueMicrotask(() => readableStreamClose(controller));
|
||||
break;
|
||||
}
|
||||
controller.enqueue(value);
|
||||
}
|
||||
},
|
||||
type: "bytes"
|
||||
});
|
||||
internalResponse.body.stream = byteStream;
|
||||
}
|
||||
}
|
||||
__name(fetchFinale, "fetchFinale");
|
||||
@@ -10957,6 +10944,7 @@ var require_util3 = __commonJS({
|
||||
var { kReadyState, kController, kResponse, kBinaryType, kWebSocketURL } = require_symbols3();
|
||||
var { states, opcodes } = require_constants4();
|
||||
var { MessageEvent, ErrorEvent } = require_events();
|
||||
var { isUtf8 } = require("node:buffer");
|
||||
function isConnecting(ws) {
|
||||
return ws[kReadyState] === states.CONNECTING;
|
||||
}
|
||||
@@ -10985,7 +10973,7 @@ var require_util3 = __commonJS({
|
||||
let dataForEvent;
|
||||
if (type === opcodes.TEXT) {
|
||||
try {
|
||||
dataForEvent = new TextDecoder("utf-8", { fatal: true }).decode(data);
|
||||
dataForEvent = utf8Decode(data);
|
||||
} catch {
|
||||
failWebsocketConnection(ws, "Received invalid UTF-8 in text frame.");
|
||||
return;
|
||||
@@ -11055,6 +11043,19 @@ var require_util3 = __commonJS({
|
||||
}
|
||||
}
|
||||
__name(failWebsocketConnection, "failWebsocketConnection");
|
||||
var hasIntl = typeof process.versions.icu === "string";
|
||||
var fatalDecoder = hasIntl ? new TextDecoder("utf-8", { fatal: true }) : void 0;
|
||||
var utf8Decode = hasIntl ? fatalDecoder.decode.bind(fatalDecoder) : !isUtf8 ? function() {
|
||||
process.emitWarning("ICU is not supported and no fallback exists. Please upgrade to at least Node v18.14.0.", {
|
||||
code: "UNDICI-WS-NO-ICU"
|
||||
});
|
||||
throw new TypeError("Invalid utf-8 received.");
|
||||
} : function(buffer) {
|
||||
if (isUtf8(buffer)) {
|
||||
return buffer.toString("utf-8");
|
||||
}
|
||||
throw new TypeError("Invalid utf-8 received.");
|
||||
};
|
||||
module2.exports = {
|
||||
isConnecting,
|
||||
isEstablished,
|
||||
@@ -11064,7 +11065,8 @@ var require_util3 = __commonJS({
|
||||
isValidSubprotocol,
|
||||
isValidStatusCode,
|
||||
failWebsocketConnection,
|
||||
websocketMessageReceived
|
||||
websocketMessageReceived,
|
||||
utf8Decode
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -11288,7 +11290,7 @@ var require_receiver = __commonJS({
|
||||
var { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants4();
|
||||
var { kReadyState, kSentClose, kResponse, kReceivedClose } = require_symbols3();
|
||||
var { channels } = require_diagnostics();
|
||||
var { isValidStatusCode, failWebsocketConnection, websocketMessageReceived } = require_util3();
|
||||
var { isValidStatusCode, failWebsocketConnection, websocketMessageReceived, utf8Decode } = require_util3();
|
||||
var { WebsocketFrameSend } = require_frame();
|
||||
var ByteParser = class extends Writable {
|
||||
static {
|
||||
@@ -11495,7 +11497,7 @@ var require_receiver = __commonJS({
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
reason = new TextDecoder("utf-8", { fatal: true }).decode(reason);
|
||||
reason = utf8Decode(reason);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
// Refer to tools/dep_updaters/update-undici.sh
|
||||
#ifndef SRC_UNDICI_VERSION_H_
|
||||
#define SRC_UNDICI_VERSION_H_
|
||||
#define UNDICI_VERSION "6.11.1"
|
||||
#define UNDICI_VERSION "6.13.0"
|
||||
#endif // SRC_UNDICI_VERSION_H_
|
||||
Reference in new issue
Block a user