@blockrun/clawrouter 0.12.239 → 0.12.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +423 -99
- package/dist/index.js +423 -99
- package/package.json +12 -9
package/dist/cli.js
CHANGED
|
@@ -57038,6 +57038,7 @@ var require_symbols = __commonJS({
|
|
|
57038
57038
|
kCounter: /* @__PURE__ */ Symbol("socket request counter"),
|
|
57039
57039
|
kMaxResponseSize: /* @__PURE__ */ Symbol("max response size"),
|
|
57040
57040
|
kHTTP2Session: /* @__PURE__ */ Symbol("http2Session"),
|
|
57041
|
+
kHTTP2Options: /* @__PURE__ */ Symbol("http2 options"),
|
|
57041
57042
|
kHTTP2SessionState: /* @__PURE__ */ Symbol("http2Session state"),
|
|
57042
57043
|
kRetryHandlerDefaultRetry: /* @__PURE__ */ Symbol("retry agent default retry"),
|
|
57043
57044
|
kConstruct: /* @__PURE__ */ Symbol("constructable"),
|
|
@@ -59806,14 +59807,26 @@ var require_connect = __commonJS({
|
|
|
59806
59807
|
} else {
|
|
59807
59808
|
assert10(!httpSocket, "httpSocket can only be sent on TLS update");
|
|
59808
59809
|
port = port || 80;
|
|
59809
|
-
|
|
59810
|
+
const connectOptions = {
|
|
59810
59811
|
highWaterMark: 64 * 1024,
|
|
59811
59812
|
// Same as nodejs fs streams.
|
|
59812
59813
|
...options,
|
|
59813
59814
|
localAddress,
|
|
59814
59815
|
port,
|
|
59815
59816
|
host: hostname
|
|
59816
|
-
}
|
|
59817
|
+
};
|
|
59818
|
+
const family = net3.isIP(hostname);
|
|
59819
|
+
if (family !== 0 && servername && servername !== hostname) {
|
|
59820
|
+
connectOptions.host = servername;
|
|
59821
|
+
connectOptions.lookup = (_hostname, lookupOptions, cb) => {
|
|
59822
|
+
if (lookupOptions.all) {
|
|
59823
|
+
cb(null, [{ address: hostname, family }]);
|
|
59824
|
+
} else {
|
|
59825
|
+
cb(null, hostname, family);
|
|
59826
|
+
}
|
|
59827
|
+
};
|
|
59828
|
+
}
|
|
59829
|
+
socket = net3.connect(connectOptions);
|
|
59817
59830
|
if (useH2c === true) {
|
|
59818
59831
|
socket.alpnProtocol = "h2";
|
|
59819
59832
|
}
|
|
@@ -64253,20 +64266,20 @@ var require_client_h1 = __commonJS({
|
|
|
64253
64266
|
}
|
|
64254
64267
|
function clearIdleSocketValidation(socket) {
|
|
64255
64268
|
if (socket[kIdleSocketValidationTimeout]) {
|
|
64256
|
-
|
|
64269
|
+
clearTimeout(socket[kIdleSocketValidationTimeout]);
|
|
64257
64270
|
socket[kIdleSocketValidationTimeout] = null;
|
|
64258
64271
|
}
|
|
64259
64272
|
socket[kIdleSocketValidation] = 0;
|
|
64260
64273
|
}
|
|
64261
64274
|
function scheduleIdleSocketValidation(client, socket) {
|
|
64262
64275
|
socket[kIdleSocketValidation] = 1;
|
|
64263
|
-
socket[kIdleSocketValidationTimeout] =
|
|
64276
|
+
socket[kIdleSocketValidationTimeout] = setTimeout(() => {
|
|
64264
64277
|
socket[kIdleSocketValidationTimeout] = null;
|
|
64265
64278
|
socket[kIdleSocketValidation] = 2;
|
|
64266
64279
|
if (client[kSocket] === socket && !socket.destroyed) {
|
|
64267
64280
|
client[kResume]();
|
|
64268
64281
|
}
|
|
64269
|
-
});
|
|
64282
|
+
}, 0);
|
|
64270
64283
|
socket[kIdleSocketValidationTimeout].unref?.();
|
|
64271
64284
|
}
|
|
64272
64285
|
function resumeH1(client) {
|
|
@@ -64790,10 +64803,7 @@ var require_client_h2 = __commonJS({
|
|
|
64790
64803
|
kStrictContentLength,
|
|
64791
64804
|
kOnError,
|
|
64792
64805
|
kMaxConcurrentStreams,
|
|
64793
|
-
kPingInterval,
|
|
64794
64806
|
kHTTP2Session,
|
|
64795
|
-
kHTTP2InitialWindowSize,
|
|
64796
|
-
kHTTP2ConnectionWindowSize,
|
|
64797
64807
|
kHostAuthority,
|
|
64798
64808
|
kResume,
|
|
64799
64809
|
kSize,
|
|
@@ -64805,7 +64815,8 @@ var require_client_h2 = __commonJS({
|
|
|
64805
64815
|
kEnableConnectProtocol,
|
|
64806
64816
|
kRemoteSettings,
|
|
64807
64817
|
kHTTP2Stream,
|
|
64808
|
-
kHTTP2SessionState
|
|
64818
|
+
kHTTP2SessionState,
|
|
64819
|
+
kHTTP2Options
|
|
64809
64820
|
} = require_symbols();
|
|
64810
64821
|
var { channels } = require_diagnostics();
|
|
64811
64822
|
var kOpenStreams = /* @__PURE__ */ Symbol("open streams");
|
|
@@ -64814,6 +64825,9 @@ var require_client_h2 = __commonJS({
|
|
|
64814
64825
|
var kRequestStreamCleanup = /* @__PURE__ */ Symbol("request stream cleanup");
|
|
64815
64826
|
var kRequestStreamState = /* @__PURE__ */ Symbol("request stream state");
|
|
64816
64827
|
var kReceivedGoAway = /* @__PURE__ */ Symbol("received goaway");
|
|
64828
|
+
var kGoAwayReplayAttempts = /* @__PURE__ */ Symbol("goaway replay attempts");
|
|
64829
|
+
var kRefusedStreamRetry = /* @__PURE__ */ Symbol("refused stream retry");
|
|
64830
|
+
var MAX_GOAWAY_REPLAY_ATTEMPTS = 1;
|
|
64817
64831
|
var extractBody;
|
|
64818
64832
|
var http23;
|
|
64819
64833
|
try {
|
|
@@ -64911,10 +64925,15 @@ var require_client_h2 = __commonJS({
|
|
|
64911
64925
|
client[kPendingIdx] = client[kRunningIdx];
|
|
64912
64926
|
}
|
|
64913
64927
|
}
|
|
64914
|
-
function
|
|
64928
|
+
function canReplayRequest(request2) {
|
|
64915
64929
|
const { body } = request2;
|
|
64916
64930
|
return body == null || util5.isBuffer(body) || util5.isBlobLike(body);
|
|
64917
64931
|
}
|
|
64932
|
+
function registerGoAwayRefusal(request2) {
|
|
64933
|
+
const attempts = (request2[kGoAwayReplayAttempts] ?? 0) + 1;
|
|
64934
|
+
request2[kGoAwayReplayAttempts] = attempts;
|
|
64935
|
+
return attempts <= MAX_GOAWAY_REPLAY_ATTEMPTS;
|
|
64936
|
+
}
|
|
64918
64937
|
function closeStream(stream4, code = NGHTTP2_REFUSED_STREAM) {
|
|
64919
64938
|
if (stream4 != null && !stream4.destroyed && !stream4.closed) {
|
|
64920
64939
|
try {
|
|
@@ -64926,15 +64945,30 @@ var require_client_h2 = __commonJS({
|
|
|
64926
64945
|
function detachRequestStreamForClose(request2) {
|
|
64927
64946
|
const stream4 = request2[kRequestStream];
|
|
64928
64947
|
clearRequestStream(request2);
|
|
64948
|
+
severRequestStream(stream4);
|
|
64929
64949
|
return stream4;
|
|
64930
64950
|
}
|
|
64951
|
+
function severRequestStream(stream4) {
|
|
64952
|
+
if (stream4 == null || stream4[kRequestStreamState] == null) {
|
|
64953
|
+
return;
|
|
64954
|
+
}
|
|
64955
|
+
stream4[kRequestStreamState] = null;
|
|
64956
|
+
stream4.off("close", completeRequestStream);
|
|
64957
|
+
stream4.off("close", onUpgradeStreamClose);
|
|
64958
|
+
if (stream4[kHTTP2Session] != null) {
|
|
64959
|
+
closeStreamSession(stream4);
|
|
64960
|
+
}
|
|
64961
|
+
if (!stream4.destroyed && !stream4.closed) {
|
|
64962
|
+
stream4.once("error", noop2);
|
|
64963
|
+
}
|
|
64964
|
+
}
|
|
64931
64965
|
function connectH2(client, socket) {
|
|
64932
64966
|
client[kSocket] = socket;
|
|
64933
|
-
const http2InitialWindowSize = client[
|
|
64934
|
-
const http2ConnectionWindowSize = client[
|
|
64967
|
+
const http2InitialWindowSize = client[kHTTP2Options].sessionOptions?.initialWindowSize;
|
|
64968
|
+
const http2ConnectionWindowSize = client[kHTTP2Options].connectionWindowSize;
|
|
64935
64969
|
const session = http23.connect(client[kUrl], {
|
|
64936
64970
|
createConnection: () => socket,
|
|
64937
|
-
peerMaxConcurrentStreams: client[
|
|
64971
|
+
peerMaxConcurrentStreams: client[kHTTP2Options].maxConcurrentStreams,
|
|
64938
64972
|
settings: {
|
|
64939
64973
|
// TODO(metcoder95): add support for PUSH
|
|
64940
64974
|
enablePush: false,
|
|
@@ -64947,13 +64981,16 @@ var require_client_h2 = __commonJS({
|
|
|
64947
64981
|
session[kSocket] = socket;
|
|
64948
64982
|
session[kHTTP2SessionState] = {
|
|
64949
64983
|
idleTimeout: null,
|
|
64984
|
+
// Armed while the peer advertises MAX_CONCURRENT_STREAMS = 0 and we have
|
|
64985
|
+
// work that cannot start. See setNoStreamsTimeout.
|
|
64986
|
+
noStreamsTimeout: null,
|
|
64950
64987
|
// Sockets start out ref'd. Session ref/unref proxies to the socket, so a
|
|
64951
64988
|
// single cached flag lets us skip redundant uv ref/unref calls, provided
|
|
64952
64989
|
// every ref/unref of the session or its socket goes through
|
|
64953
64990
|
// refH2Session/unrefH2Session.
|
|
64954
64991
|
refed: true,
|
|
64955
64992
|
ping: {
|
|
64956
|
-
interval: client[
|
|
64993
|
+
interval: client[kHTTP2Options].pingInterval === 0 ? null : setInterval(onHttp2SendPing, client[kHTTP2Options].pingInterval, session).unref()
|
|
64957
64994
|
}
|
|
64958
64995
|
};
|
|
64959
64996
|
session[kReceivedGoAway] = false;
|
|
@@ -65058,8 +65095,48 @@ var require_client_h2 = __commonJS({
|
|
|
65058
65095
|
} else {
|
|
65059
65096
|
clearHttp2IdleTimeout(session);
|
|
65060
65097
|
}
|
|
65098
|
+
if (client[kMaxConcurrentStreams] === 0 && client[kRunning] === 0 && client[kPending] > 0) {
|
|
65099
|
+
setNoStreamsTimeout(session);
|
|
65100
|
+
} else {
|
|
65101
|
+
clearNoStreamsTimeout(session);
|
|
65102
|
+
}
|
|
65061
65103
|
}
|
|
65062
65104
|
}
|
|
65105
|
+
function clearNoStreamsTimeout(session) {
|
|
65106
|
+
const state = session[kHTTP2SessionState];
|
|
65107
|
+
if (state?.noStreamsTimeout != null) {
|
|
65108
|
+
clearTimeout(state.noStreamsTimeout);
|
|
65109
|
+
state.noStreamsTimeout = null;
|
|
65110
|
+
}
|
|
65111
|
+
}
|
|
65112
|
+
function setNoStreamsTimeout(session) {
|
|
65113
|
+
const client = session[kClient];
|
|
65114
|
+
const state = session[kHTTP2SessionState];
|
|
65115
|
+
const timeout = client[kHeadersTimeout];
|
|
65116
|
+
if (!timeout || state.noStreamsTimeout != null) {
|
|
65117
|
+
return;
|
|
65118
|
+
}
|
|
65119
|
+
state.noStreamsTimeout = setTimeout(onNoStreamsTimeout, timeout, session).unref();
|
|
65120
|
+
}
|
|
65121
|
+
function onNoStreamsTimeout(session) {
|
|
65122
|
+
const client = session[kClient];
|
|
65123
|
+
const state = session[kHTTP2SessionState];
|
|
65124
|
+
state.noStreamsTimeout = null;
|
|
65125
|
+
if (client[kHTTP2Session] !== session || client[kMaxConcurrentStreams] !== 0 || client[kRunning] !== 0 || client[kPending] === 0) {
|
|
65126
|
+
return;
|
|
65127
|
+
}
|
|
65128
|
+
const err = new HeadersTimeoutError(
|
|
65129
|
+
`HTTP/2: server did not accept a new stream within ${client[kHeadersTimeout]}`
|
|
65130
|
+
);
|
|
65131
|
+
const requests = client[kQueue].splice(client[kPendingIdx]);
|
|
65132
|
+
for (let i = 0; i < requests.length; i++) {
|
|
65133
|
+
if (requests[i] != null) {
|
|
65134
|
+
util5.errorRequest(client, requests[i], err);
|
|
65135
|
+
}
|
|
65136
|
+
}
|
|
65137
|
+
session[kError] = err;
|
|
65138
|
+
resetHttp2Session(session, err);
|
|
65139
|
+
}
|
|
65063
65140
|
function clearHttp2IdleTimeout(session) {
|
|
65064
65141
|
const state = session[kHTTP2SessionState];
|
|
65065
65142
|
if (state?.idleTimeout != null) {
|
|
@@ -65166,7 +65243,7 @@ var require_client_h2 = __commonJS({
|
|
|
65166
65243
|
const request2 = client[kQueue][i];
|
|
65167
65244
|
if (request2 != null) {
|
|
65168
65245
|
streamsToClose.push(detachRequestStreamForClose(request2));
|
|
65169
|
-
if (
|
|
65246
|
+
if (canReplayRequest(request2) && registerGoAwayRefusal(request2)) {
|
|
65170
65247
|
retriableRequests.push(request2);
|
|
65171
65248
|
} else {
|
|
65172
65249
|
util5.errorRequest(client, request2, err);
|
|
@@ -65187,6 +65264,7 @@ var require_client_h2 = __commonJS({
|
|
|
65187
65264
|
client[kHTTP2Session] = null;
|
|
65188
65265
|
}
|
|
65189
65266
|
clearHttp2IdleTimeout(this);
|
|
65267
|
+
clearNoStreamsTimeout(this);
|
|
65190
65268
|
if (!this.closed && !this.destroyed) {
|
|
65191
65269
|
this.close();
|
|
65192
65270
|
}
|
|
@@ -65203,6 +65281,7 @@ var require_client_h2 = __commonJS({
|
|
|
65203
65281
|
client[kHTTP2Session] = null;
|
|
65204
65282
|
}
|
|
65205
65283
|
clearHttp2IdleTimeout(this);
|
|
65284
|
+
clearNoStreamsTimeout(this);
|
|
65206
65285
|
if (state.ping.interval != null) {
|
|
65207
65286
|
clearInterval(state.ping.interval);
|
|
65208
65287
|
state.ping.interval = null;
|
|
@@ -65278,6 +65357,12 @@ var require_client_h2 = __commonJS({
|
|
|
65278
65357
|
releaseRequestStream(this);
|
|
65279
65358
|
if (state.pendingEnd && !state.request.aborted && !state.request.completed) {
|
|
65280
65359
|
state.request.onResponseEnd(state.trailers || {});
|
|
65360
|
+
} else if (!state.request.aborted && !state.request.completed) {
|
|
65361
|
+
util5.errorRequest(
|
|
65362
|
+
state.client,
|
|
65363
|
+
state.request,
|
|
65364
|
+
new InformationalError("HTTP/2: stream closed before the response was complete")
|
|
65365
|
+
);
|
|
65281
65366
|
}
|
|
65282
65367
|
finalizeRequest(state);
|
|
65283
65368
|
closeStreamSession(this);
|
|
@@ -65677,6 +65762,20 @@ var require_client_h2 = __commonJS({
|
|
|
65677
65762
|
state.abort(new InformationalError("HTTP/2: stream half-closed (remote)"), true);
|
|
65678
65763
|
}
|
|
65679
65764
|
}
|
|
65765
|
+
function retryRefusedStream(stream4, state) {
|
|
65766
|
+
const { client, request: request2 } = state;
|
|
65767
|
+
if (state.responseReceived || request2.aborted || request2.completed || request2[kRefusedStreamRetry] || !canReplayRequest(request2)) {
|
|
65768
|
+
return false;
|
|
65769
|
+
}
|
|
65770
|
+
request2[kRefusedStreamRetry] = true;
|
|
65771
|
+
detachRequestStreamForClose(request2);
|
|
65772
|
+
state.stream = null;
|
|
65773
|
+
state.requestFinalized = true;
|
|
65774
|
+
completeRequest(client, request2);
|
|
65775
|
+
client[kQueue].splice(client[kPendingIdx], 0, request2);
|
|
65776
|
+
client[kResume]();
|
|
65777
|
+
return true;
|
|
65778
|
+
}
|
|
65680
65779
|
function onError(err) {
|
|
65681
65780
|
const stream4 = this;
|
|
65682
65781
|
const state = stream4[kRequestStreamState];
|
|
@@ -65684,6 +65783,12 @@ var require_client_h2 = __commonJS({
|
|
|
65684
65783
|
return;
|
|
65685
65784
|
}
|
|
65686
65785
|
stream4.off("error", onError);
|
|
65786
|
+
if (typeof stream4.rstCode === "number" && stream4.rstCode !== NGHTTP2_NO_ERROR) {
|
|
65787
|
+
err.http2ErrorCode = stream4.rstCode;
|
|
65788
|
+
}
|
|
65789
|
+
if (stream4.rstCode === NGHTTP2_REFUSED_STREAM && retryRefusedStream(stream4, state)) {
|
|
65790
|
+
return;
|
|
65791
|
+
}
|
|
65687
65792
|
state.abort(err);
|
|
65688
65793
|
}
|
|
65689
65794
|
function onFrameError(type, code) {
|
|
@@ -65965,10 +66070,8 @@ var require_client = __commonJS({
|
|
|
65965
66070
|
kHTTPContext,
|
|
65966
66071
|
kMaxConcurrentStreams,
|
|
65967
66072
|
kHostAuthority,
|
|
65968
|
-
kHTTP2InitialWindowSize,
|
|
65969
|
-
kHTTP2ConnectionWindowSize,
|
|
65970
66073
|
kResume,
|
|
65971
|
-
|
|
66074
|
+
kHTTP2Options
|
|
65972
66075
|
} = require_symbols();
|
|
65973
66076
|
var connectH1 = require_client_h1();
|
|
65974
66077
|
var connectH2 = require_client_h2();
|
|
@@ -65981,6 +66084,14 @@ var require_client = __commonJS({
|
|
|
65981
66084
|
function getPipelining(client) {
|
|
65982
66085
|
return client[kPipelining] ?? client[kHTTPContext]?.defaultPipelining ?? 1;
|
|
65983
66086
|
}
|
|
66087
|
+
var h2NamespaceOptsWarning = false;
|
|
66088
|
+
function emitH2OptionsNamespaceWarning(optName) {
|
|
66089
|
+
if (h2NamespaceOptsWarning === true) return;
|
|
66090
|
+
process.emitWarning(`Use h2Options.${optName} instead. ${optName} for H2 will be deprecated in future major.`, {
|
|
66091
|
+
code: "UNDICI-H2-OPTIONS"
|
|
66092
|
+
});
|
|
66093
|
+
h2NamespaceOptsWarning = true;
|
|
66094
|
+
}
|
|
65984
66095
|
function getMaxConcurrent(client) {
|
|
65985
66096
|
if (client[kHTTPContext]?.version === "h2") {
|
|
65986
66097
|
return client[kMaxConcurrentStreams];
|
|
@@ -66024,7 +66135,8 @@ var require_client = __commonJS({
|
|
|
66024
66135
|
initialWindowSize,
|
|
66025
66136
|
connectionWindowSize,
|
|
66026
66137
|
pingInterval,
|
|
66027
|
-
webSocket
|
|
66138
|
+
webSocket,
|
|
66139
|
+
h2Options
|
|
66028
66140
|
} = {}) {
|
|
66029
66141
|
if (keepAlive !== void 0) {
|
|
66030
66142
|
throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
|
|
@@ -66087,20 +66199,45 @@ var require_client = __commonJS({
|
|
|
66087
66199
|
if (allowH2 != null && typeof allowH2 !== "boolean") {
|
|
66088
66200
|
throw new InvalidArgumentError("allowH2 must be a valid boolean value");
|
|
66089
66201
|
}
|
|
66090
|
-
if (
|
|
66091
|
-
|
|
66092
|
-
|
|
66093
|
-
|
|
66094
|
-
|
|
66095
|
-
|
|
66096
|
-
|
|
66097
|
-
|
|
66098
|
-
|
|
66099
|
-
|
|
66100
|
-
|
|
66101
|
-
|
|
66102
|
-
|
|
66103
|
-
|
|
66202
|
+
if (allowH2 !== false) {
|
|
66203
|
+
if (h2Options != null) {
|
|
66204
|
+
if (h2Options.useH2c != null && typeof h2Options.useH2c !== "boolean") {
|
|
66205
|
+
throw new InvalidArgumentError("h2Options.useH2c must be a valid boolean value");
|
|
66206
|
+
}
|
|
66207
|
+
if (h2Options.settings?.initialWindowSize != null && (!Number.isInteger(h2Options.settings.initialWindowSize) || h2Options.settings.initialWindowSize < 1)) {
|
|
66208
|
+
throw new InvalidArgumentError("h2Options.settings.initialWindowSize must be a positive integer, greater than 0");
|
|
66209
|
+
}
|
|
66210
|
+
if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.maxConcurrentStreams < 1)) {
|
|
66211
|
+
throw new InvalidArgumentError("h2Options.maxConcurrentStreams must be a positive integer, greater than 0");
|
|
66212
|
+
}
|
|
66213
|
+
if (h2Options.connectionWindowSize != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.connectionWindowSize < 1)) {
|
|
66214
|
+
throw new InvalidArgumentError("h2Options.connectionWindowSize must be a positive integer, greater than 0");
|
|
66215
|
+
}
|
|
66216
|
+
if (h2Options.pingInterval != null && (typeof h2Options.pingInterval !== "number" || !Number.isInteger(h2Options.pingInterval) || h2Options.pingInterval < 0)) {
|
|
66217
|
+
throw new InvalidArgumentError("h2Options.pingInterval must be a positive integer, greater or equal to 0");
|
|
66218
|
+
}
|
|
66219
|
+
} else {
|
|
66220
|
+
if (useH2c != null && typeof useH2c !== "boolean") {
|
|
66221
|
+
emitH2OptionsNamespaceWarning("useH2c");
|
|
66222
|
+
throw new InvalidArgumentError("useH2c must be a valid boolean value");
|
|
66223
|
+
}
|
|
66224
|
+
if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) {
|
|
66225
|
+
emitH2OptionsNamespaceWarning("maxConcurrentStreams");
|
|
66226
|
+
throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0");
|
|
66227
|
+
}
|
|
66228
|
+
if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
|
|
66229
|
+
emitH2OptionsNamespaceWarning("initialWindowSize");
|
|
66230
|
+
throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
|
|
66231
|
+
}
|
|
66232
|
+
if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
|
|
66233
|
+
emitH2OptionsNamespaceWarning("connectionWindowSize");
|
|
66234
|
+
throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
|
|
66235
|
+
}
|
|
66236
|
+
if (pingInterval != null && (typeof pingInterval !== "number" || !Number.isInteger(pingInterval) || pingInterval < 0)) {
|
|
66237
|
+
emitH2OptionsNamespaceWarning("pingInterval");
|
|
66238
|
+
throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
|
|
66239
|
+
}
|
|
66240
|
+
}
|
|
66104
66241
|
}
|
|
66105
66242
|
super({ webSocket });
|
|
66106
66243
|
if (typeof connect4 !== "function") {
|
|
@@ -66108,8 +66245,8 @@ var require_client = __commonJS({
|
|
|
66108
66245
|
...tls2,
|
|
66109
66246
|
maxCachedSessions,
|
|
66110
66247
|
allowH2,
|
|
66111
|
-
useH2c,
|
|
66112
66248
|
socketPath,
|
|
66249
|
+
useH2c: h2Options?.useH2c ?? useH2c,
|
|
66113
66250
|
timeout: connectTimeout,
|
|
66114
66251
|
...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
|
|
66115
66252
|
...connect4
|
|
@@ -66144,10 +66281,21 @@ var require_client = __commonJS({
|
|
|
66144
66281
|
this[kClosedResolve] = null;
|
|
66145
66282
|
this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1;
|
|
66146
66283
|
this[kHTTPContext] = null;
|
|
66147
|
-
this[
|
|
66148
|
-
|
|
66149
|
-
|
|
66150
|
-
|
|
66284
|
+
this[kHTTP2Options] = {
|
|
66285
|
+
pingInterval: h2Options?.pingInterval ?? pingInterval ?? 6e4,
|
|
66286
|
+
connectionWindowSize: h2Options?.connectionWindowSize ?? connectionWindowSize ?? 524288,
|
|
66287
|
+
maxConcurrentStreams: h2Options?.maxConcurrentStreams ?? maxConcurrentStreams ?? 100,
|
|
66288
|
+
// Max peerConcurrentStreams for a Node h2 server
|
|
66289
|
+
sessionOptions: {
|
|
66290
|
+
// HTTP/2 window sizes are set to higher defaults than Node.js core for better performance:
|
|
66291
|
+
// - initialWindowSize: 262144 (256KB) vs Node.js default 65535 (64KB - 1)
|
|
66292
|
+
// Allows more data to be sent before requiring acknowledgment, improving throughput
|
|
66293
|
+
// especially on high-latency networks. This matches common production HTTP/2 servers.
|
|
66294
|
+
// - connectionWindowSize: 524288 (512KB) vs Node.js default (none set)
|
|
66295
|
+
// Provides better flow control for the entire connection across multiple streams.
|
|
66296
|
+
initialWindowSize: h2Options?.initialWindowSize ?? initialWindowSize ?? 262144
|
|
66297
|
+
}
|
|
66298
|
+
};
|
|
66151
66299
|
this[kQueue] = [];
|
|
66152
66300
|
this[kRunningIdx] = 0;
|
|
66153
66301
|
this[kPendingIdx] = 0;
|
|
@@ -66432,6 +66580,7 @@ var require_client = __commonJS({
|
|
|
66432
66580
|
return;
|
|
66433
66581
|
}
|
|
66434
66582
|
if (!client[kHTTPContext]) {
|
|
66583
|
+
client[kServerName] = request2.servername;
|
|
66435
66584
|
connect3(client);
|
|
66436
66585
|
return;
|
|
66437
66586
|
}
|
|
@@ -67842,7 +67991,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
67842
67991
|
var DispatcherBase = require_dispatcher_base();
|
|
67843
67992
|
var { InvalidArgumentError } = require_errors();
|
|
67844
67993
|
var { Socks5Client, STATES } = require_socks5_client();
|
|
67845
|
-
var { kDispatch, kClose, kDestroy } = require_symbols();
|
|
67994
|
+
var { kBusy, kConnected, kDispatch, kClose, kDestroy } = require_symbols();
|
|
67846
67995
|
var Pool = require_pool();
|
|
67847
67996
|
var buildConnector = require_connect();
|
|
67848
67997
|
var { debuglog } = __require("util");
|
|
@@ -68000,6 +68149,17 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
68000
68149
|
}
|
|
68001
68150
|
});
|
|
68002
68151
|
this[kPools].set(originKey, pool);
|
|
68152
|
+
const closePoolIfUnused = () => {
|
|
68153
|
+
if (this[kPools].get(originKey) !== pool || pool[kConnected] > 0 || pool[kBusy]) {
|
|
68154
|
+
return;
|
|
68155
|
+
}
|
|
68156
|
+
this[kPools].delete(originKey);
|
|
68157
|
+
if (!pool.destroyed) {
|
|
68158
|
+
pool.close();
|
|
68159
|
+
}
|
|
68160
|
+
};
|
|
68161
|
+
pool.on("disconnect", closePoolIfUnused);
|
|
68162
|
+
pool.on("connectionError", closePoolIfUnused);
|
|
68003
68163
|
}
|
|
68004
68164
|
return pool[kDispatch](opts, handler);
|
|
68005
68165
|
} catch (err) {
|
|
@@ -68384,7 +68544,7 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
68384
68544
|
}
|
|
68385
68545
|
#getProxyAgentForUrl(url2) {
|
|
68386
68546
|
let { protocol, host: hostname, port } = url2;
|
|
68387
|
-
hostname = hostname.replace(/:\d*$/, "").toLowerCase();
|
|
68547
|
+
hostname = hostname.replace(/:\d*$/, "").replace(/^\[(.+)\]$/, "$1").toLowerCase();
|
|
68388
68548
|
port = Number.parseInt(port, 10) || DEFAULT_PORTS3[protocol] || 0;
|
|
68389
68549
|
if (!this.#shouldProxy(hostname, port)) {
|
|
68390
68550
|
return this[kNoProxyAgent];
|
|
@@ -68427,11 +68587,22 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
68427
68587
|
if (!entry) {
|
|
68428
68588
|
continue;
|
|
68429
68589
|
}
|
|
68430
|
-
|
|
68590
|
+
let hostname, port;
|
|
68591
|
+
const ipv6WithPort = entry.match(/^\[(.+)\]:(\d+)$/);
|
|
68592
|
+
if (ipv6WithPort) {
|
|
68593
|
+
hostname = ipv6WithPort[1];
|
|
68594
|
+
port = Number.parseInt(ipv6WithPort[2], 10);
|
|
68595
|
+
} else {
|
|
68596
|
+
const unbracketed = entry.replace(/^\[(.+)\]$/, "$1");
|
|
68597
|
+
const colonCount = (unbracketed.match(/:/g) || []).length;
|
|
68598
|
+
const parsed = colonCount === 1 && unbracketed.match(/^(.+):(\d+)$/);
|
|
68599
|
+
hostname = parsed ? parsed[1] : unbracketed;
|
|
68600
|
+
port = parsed ? Number.parseInt(parsed[2], 10) : 0;
|
|
68601
|
+
}
|
|
68431
68602
|
noProxyEntries.push({
|
|
68432
68603
|
// strip leading dot or asterisk with dot
|
|
68433
|
-
hostname:
|
|
68434
|
-
port
|
|
68604
|
+
hostname: hostname.replace(/^\*?\./, "").toLowerCase(),
|
|
68605
|
+
port
|
|
68435
68606
|
});
|
|
68436
68607
|
}
|
|
68437
68608
|
this.#noProxyValue = noProxyValue;
|
|
@@ -68653,6 +68824,10 @@ var require_retry_handler = __commonJS({
|
|
|
68653
68824
|
setTimeout(() => cb(null), retryTimeout);
|
|
68654
68825
|
}
|
|
68655
68826
|
onResponseStart(controller, statusCode, headers, statusMessage) {
|
|
68827
|
+
if (statusCode < 200) {
|
|
68828
|
+
this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
|
|
68829
|
+
return;
|
|
68830
|
+
}
|
|
68656
68831
|
this.error = null;
|
|
68657
68832
|
this.retryCount += 1;
|
|
68658
68833
|
this.statusCode = statusCode;
|
|
@@ -68696,7 +68871,7 @@ var require_retry_handler = __commonJS({
|
|
|
68696
68871
|
if (this.end == null) {
|
|
68697
68872
|
if (statusCode === 206) {
|
|
68698
68873
|
const range = parseRangeHeader(headers["content-range"]);
|
|
68699
|
-
if (range == null) {
|
|
68874
|
+
if (range == null || range.end == null) {
|
|
68700
68875
|
this.headersSent = true;
|
|
68701
68876
|
this.handler.onResponseStart?.(
|
|
68702
68877
|
this.controllerProxy,
|
|
@@ -68716,7 +68891,7 @@ var require_retry_handler = __commonJS({
|
|
|
68716
68891
|
this.start = start;
|
|
68717
68892
|
this.end = end;
|
|
68718
68893
|
}
|
|
68719
|
-
if (this.end == null) {
|
|
68894
|
+
if (this.end == null && this.opts.method !== "HEAD") {
|
|
68720
68895
|
const contentLength = headers["content-length"];
|
|
68721
68896
|
this.end = contentLength != null ? Number(contentLength) - 1 : null;
|
|
68722
68897
|
}
|
|
@@ -68917,7 +69092,6 @@ var require_readable = __commonJS({
|
|
|
68917
69092
|
var kContentLength = /* @__PURE__ */ Symbol("kContentLength");
|
|
68918
69093
|
var kUsed = /* @__PURE__ */ Symbol("kUsed");
|
|
68919
69094
|
var kBytesRead = /* @__PURE__ */ Symbol("kBytesRead");
|
|
68920
|
-
var kPreservedBuffer = /* @__PURE__ */ Symbol("kPreservedBuffer");
|
|
68921
69095
|
var noop2 = () => {
|
|
68922
69096
|
};
|
|
68923
69097
|
var BodyReadable = class extends Readable2 {
|
|
@@ -69156,21 +69330,6 @@ var require_readable = __commonJS({
|
|
|
69156
69330
|
*/
|
|
69157
69331
|
setEncoding(encoding) {
|
|
69158
69332
|
if (Buffer.isEncoding(encoding)) {
|
|
69159
|
-
const state = this._readableState;
|
|
69160
|
-
const buffer2 = state.buffer;
|
|
69161
|
-
if (buffer2 && state.length > 0) {
|
|
69162
|
-
const bufferIndex = state.bufferIndex ?? 0;
|
|
69163
|
-
const preserved = [];
|
|
69164
|
-
const source = typeof buffer2.slice === "function" ? buffer2.slice(bufferIndex) : buffer2;
|
|
69165
|
-
for (const data of source) {
|
|
69166
|
-
if (Buffer.isBuffer(data)) {
|
|
69167
|
-
preserved.push(data);
|
|
69168
|
-
}
|
|
69169
|
-
}
|
|
69170
|
-
if (preserved.length > 0) {
|
|
69171
|
-
this[kPreservedBuffer] = (this[kPreservedBuffer] || []).concat(preserved);
|
|
69172
|
-
}
|
|
69173
|
-
}
|
|
69174
69333
|
super.setEncoding(encoding);
|
|
69175
69334
|
}
|
|
69176
69335
|
return this;
|
|
@@ -69221,13 +69380,7 @@ var require_readable = __commonJS({
|
|
|
69221
69380
|
return;
|
|
69222
69381
|
}
|
|
69223
69382
|
const { _readableState: state } = consume2.stream;
|
|
69224
|
-
|
|
69225
|
-
if (preserved && preserved.length > 0) {
|
|
69226
|
-
for (const chunk of preserved) {
|
|
69227
|
-
consumePush(consume2, chunk);
|
|
69228
|
-
}
|
|
69229
|
-
consume2.stream[kPreservedBuffer] = null;
|
|
69230
|
-
} else if (state.bufferIndex) {
|
|
69383
|
+
if (state.bufferIndex) {
|
|
69231
69384
|
const start = state.bufferIndex;
|
|
69232
69385
|
const end = state.buffer.length;
|
|
69233
69386
|
for (let n = start; n < end; n++) {
|
|
@@ -69238,13 +69391,17 @@ var require_readable = __commonJS({
|
|
|
69238
69391
|
consumePush(consume2, chunk);
|
|
69239
69392
|
}
|
|
69240
69393
|
}
|
|
69394
|
+
const decoder2 = state.decoder;
|
|
69395
|
+
if (decoder2 != null && decoder2.lastNeed > 0) {
|
|
69396
|
+
consumePush(consume2, Buffer.from(decoder2.lastChar.subarray(0, decoder2.lastTotal - decoder2.lastNeed)));
|
|
69397
|
+
}
|
|
69241
69398
|
if (state.endEmitted) {
|
|
69242
|
-
consumeEnd(
|
|
69243
|
-
|
|
69244
|
-
consume2.stream.on("end", function() {
|
|
69245
|
-
consumeEnd(this[kConsume], this._readableState.encoding);
|
|
69246
|
-
});
|
|
69399
|
+
consumeEnd(consume2, state.encoding);
|
|
69400
|
+
return;
|
|
69247
69401
|
}
|
|
69402
|
+
consume2.stream.on("end", function() {
|
|
69403
|
+
consumeEnd(this[kConsume], this._readableState.encoding);
|
|
69404
|
+
});
|
|
69248
69405
|
consume2.stream.resume();
|
|
69249
69406
|
while (consume2.stream.read() != null) {
|
|
69250
69407
|
}
|
|
@@ -69301,6 +69458,9 @@ var require_readable = __commonJS({
|
|
|
69301
69458
|
if (consume2.body === null) {
|
|
69302
69459
|
return;
|
|
69303
69460
|
}
|
|
69461
|
+
if (typeof chunk === "string") {
|
|
69462
|
+
chunk = Buffer.from(chunk, consume2.stream._readableState.encoding);
|
|
69463
|
+
}
|
|
69304
69464
|
consume2.length += chunk.length;
|
|
69305
69465
|
consume2.body.push(chunk);
|
|
69306
69466
|
}
|
|
@@ -70285,6 +70445,7 @@ var require_mock_utils = __commonJS({
|
|
|
70285
70445
|
}
|
|
70286
70446
|
} = __require("util");
|
|
70287
70447
|
var { InvalidArgumentError } = require_errors();
|
|
70448
|
+
var requestAborted = /* @__PURE__ */ Symbol("request aborted");
|
|
70288
70449
|
function matchValue(match, value) {
|
|
70289
70450
|
if (typeof match === "string") {
|
|
70290
70451
|
return match === value;
|
|
@@ -70397,6 +70558,8 @@ var require_mock_utils = __commonJS({
|
|
|
70397
70558
|
return data;
|
|
70398
70559
|
} else if (data instanceof ArrayBuffer) {
|
|
70399
70560
|
return data;
|
|
70561
|
+
} else if (ArrayBuffer.isView(data)) {
|
|
70562
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
70400
70563
|
} else if (typeof data === "object") {
|
|
70401
70564
|
return JSON.stringify(data);
|
|
70402
70565
|
} else if (data) {
|
|
@@ -70450,6 +70613,9 @@ var require_mock_utils = __commonJS({
|
|
|
70450
70613
|
}
|
|
70451
70614
|
}
|
|
70452
70615
|
function removeTrailingSlash(path6) {
|
|
70616
|
+
if (typeof path6 !== "string") {
|
|
70617
|
+
return path6;
|
|
70618
|
+
}
|
|
70453
70619
|
while (path6.endsWith("/")) {
|
|
70454
70620
|
path6 = path6.slice(0, -1);
|
|
70455
70621
|
}
|
|
@@ -70503,30 +70669,38 @@ var require_mock_utils = __commonJS({
|
|
|
70503
70669
|
const { timesInvoked, times } = mockDispatch2;
|
|
70504
70670
|
mockDispatch2.consumed = !mockDispatch2.persist && timesInvoked >= times;
|
|
70505
70671
|
mockDispatch2.pending = timesInvoked < times;
|
|
70506
|
-
|
|
70507
|
-
|
|
70672
|
+
const hasBodyHooks = typeof handler.onBodySent === "function" || typeof handler.onRequestSent === "function";
|
|
70673
|
+
if (mockDispatch2.data.callback && (!hasBodyHooks || opts.body == null)) {
|
|
70674
|
+
const { callback, ...responseDefaults } = mockDispatch2.data;
|
|
70675
|
+
const callbackResult = callback(opts);
|
|
70508
70676
|
if (isPromise(callbackResult)) {
|
|
70509
70677
|
callbackResult.then(
|
|
70510
70678
|
(resolvedData) => {
|
|
70511
|
-
|
|
70679
|
+
if (resolvedData == null || typeof resolvedData !== "object") {
|
|
70680
|
+
handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
|
|
70681
|
+
return;
|
|
70682
|
+
}
|
|
70683
|
+
mockDispatch2.data = { ...responseDefaults, ...resolvedData };
|
|
70512
70684
|
dispatchMockReply(mockDispatches, mockDispatch2, key2, opts, handler);
|
|
70513
70685
|
},
|
|
70514
70686
|
(error) => {
|
|
70515
|
-
deleteMockDispatch(mockDispatches, key2);
|
|
70516
70687
|
handler.onResponseError(null, error);
|
|
70517
70688
|
}
|
|
70518
70689
|
);
|
|
70519
70690
|
return true;
|
|
70520
70691
|
}
|
|
70521
|
-
|
|
70692
|
+
if (callbackResult == null || typeof callbackResult !== "object") {
|
|
70693
|
+
throw new InvalidArgumentError("reply options callback must return an object");
|
|
70694
|
+
}
|
|
70695
|
+
mockDispatch2.data = { ...responseDefaults, ...callbackResult };
|
|
70522
70696
|
}
|
|
70523
70697
|
return dispatchMockReply(mockDispatches, mockDispatch2, key2, opts, handler);
|
|
70524
70698
|
}
|
|
70525
70699
|
function dispatchMockReply(mockDispatches, mockDispatch2, key2, opts, handler) {
|
|
70526
|
-
const { data:
|
|
70527
|
-
if (error !== null) {
|
|
70700
|
+
const { data: response, delay } = mockDispatch2;
|
|
70701
|
+
if (response.error !== null) {
|
|
70528
70702
|
deleteMockDispatch(mockDispatches, key2);
|
|
70529
|
-
handler.onResponseError(null, error);
|
|
70703
|
+
handler.onResponseError(null, response.error);
|
|
70530
70704
|
return true;
|
|
70531
70705
|
}
|
|
70532
70706
|
let aborted = false;
|
|
@@ -70553,30 +70727,91 @@ var require_mock_utils = __commonJS({
|
|
|
70553
70727
|
handler.onResponseError?.(controller, reason);
|
|
70554
70728
|
}
|
|
70555
70729
|
};
|
|
70730
|
+
let replyOpts = opts;
|
|
70731
|
+
const dispatches = mockDispatches;
|
|
70556
70732
|
handler.onRequestStart?.(controller, null);
|
|
70557
|
-
if (
|
|
70558
|
-
|
|
70559
|
-
|
|
70560
|
-
|
|
70561
|
-
|
|
70562
|
-
|
|
70563
|
-
|
|
70733
|
+
if (aborted) {
|
|
70734
|
+
return true;
|
|
70735
|
+
}
|
|
70736
|
+
const requestBody = dispatchRequestBody(opts.body, handler, controller, () => aborted);
|
|
70737
|
+
if (isPromise(requestBody)) {
|
|
70738
|
+
requestBody.then((body) => {
|
|
70739
|
+
if (body === requestAborted) {
|
|
70740
|
+
return;
|
|
70741
|
+
}
|
|
70742
|
+
if (body !== opts.body) {
|
|
70743
|
+
replyOpts = { ...opts, body };
|
|
70744
|
+
}
|
|
70745
|
+
sendReply();
|
|
70746
|
+
}, (error) => controller.abort(error));
|
|
70747
|
+
return true;
|
|
70748
|
+
}
|
|
70749
|
+
if (requestBody === requestAborted) {
|
|
70750
|
+
return true;
|
|
70751
|
+
}
|
|
70752
|
+
if (requestBody !== opts.body) {
|
|
70753
|
+
replyOpts = { ...opts, body: requestBody };
|
|
70754
|
+
}
|
|
70755
|
+
sendReply();
|
|
70756
|
+
function sendReply() {
|
|
70757
|
+
if (response.callback) {
|
|
70758
|
+
const { callback, ...responseDefaults } = response;
|
|
70759
|
+
let callbackResult;
|
|
70760
|
+
try {
|
|
70761
|
+
callbackResult = callback(replyOpts);
|
|
70762
|
+
} catch (err) {
|
|
70763
|
+
deleteMockDispatch(mockDispatches, key2);
|
|
70764
|
+
handler.onResponseError(null, err);
|
|
70765
|
+
return;
|
|
70766
|
+
}
|
|
70767
|
+
if (isPromise(callbackResult)) {
|
|
70768
|
+
callbackResult.then(
|
|
70769
|
+
(resolvedData) => {
|
|
70770
|
+
if (resolvedData == null || typeof resolvedData !== "object") {
|
|
70771
|
+
handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
|
|
70772
|
+
return;
|
|
70773
|
+
}
|
|
70774
|
+
mockDispatch2.data = { ...responseDefaults, ...resolvedData };
|
|
70775
|
+
handleReply(dispatches, mockDispatch2.data);
|
|
70776
|
+
},
|
|
70777
|
+
(err) => {
|
|
70778
|
+
handler.onResponseError(null, err);
|
|
70779
|
+
}
|
|
70780
|
+
);
|
|
70781
|
+
return;
|
|
70782
|
+
}
|
|
70783
|
+
if (callbackResult == null || typeof callbackResult !== "object") {
|
|
70784
|
+
throw new InvalidArgumentError("reply options callback must return an object");
|
|
70785
|
+
}
|
|
70786
|
+
mockDispatch2.data = { ...responseDefaults, ...callbackResult };
|
|
70787
|
+
handleReply(dispatches, mockDispatch2.data);
|
|
70788
|
+
return;
|
|
70789
|
+
}
|
|
70790
|
+
if (typeof delay === "number" && delay > 0) {
|
|
70791
|
+
timer2 = setTimeout(() => {
|
|
70792
|
+
timer2 = null;
|
|
70793
|
+
handleReply(dispatches);
|
|
70794
|
+
}, delay);
|
|
70795
|
+
} else {
|
|
70796
|
+
handleReply(dispatches);
|
|
70797
|
+
}
|
|
70564
70798
|
}
|
|
70565
|
-
function handleReply(mockDispatches2,
|
|
70799
|
+
function handleReply(mockDispatches2, _response = response) {
|
|
70566
70800
|
if (aborted) {
|
|
70567
70801
|
return;
|
|
70568
70802
|
}
|
|
70803
|
+
const { statusCode, data, headers, trailers } = _response;
|
|
70569
70804
|
const optsHeaders = Array.isArray(opts.headers) ? buildHeadersFromArray(opts.headers) : opts.headers;
|
|
70570
|
-
const body = typeof
|
|
70805
|
+
const body = typeof data === "function" ? data({ ...replyOpts, headers: optsHeaders }) : data;
|
|
70571
70806
|
if (isPromise(body)) {
|
|
70572
|
-
return body.then((newData) => handleReply(mockDispatches2, newData));
|
|
70807
|
+
return body.then((newData) => handleReply(mockDispatches2, { ..._response, data: newData }));
|
|
70573
70808
|
}
|
|
70574
70809
|
if (aborted) {
|
|
70575
70810
|
return;
|
|
70576
70811
|
}
|
|
70577
70812
|
const responseData = getResponseData(body);
|
|
70578
|
-
const responseHeaders = generateKeyValues(headers);
|
|
70579
|
-
const responseTrailers = generateKeyValues(trailers);
|
|
70813
|
+
const responseHeaders = generateKeyValues(headers ?? {});
|
|
70814
|
+
const responseTrailers = generateKeyValues(trailers ?? {});
|
|
70580
70815
|
controller.rawHeaders = responseHeaders;
|
|
70581
70816
|
controller.rawTrailers = responseTrailers;
|
|
70582
70817
|
handler.onResponseStart?.(controller, statusCode, parseHeaders(responseHeaders), getStatusText(statusCode));
|
|
@@ -70586,6 +70821,78 @@ var require_mock_utils = __commonJS({
|
|
|
70586
70821
|
}
|
|
70587
70822
|
return true;
|
|
70588
70823
|
}
|
|
70824
|
+
function dispatchRequestBody(body, handler, controller, isAborted2) {
|
|
70825
|
+
if (typeof handler.onBodySent !== "function" && typeof handler.onRequestSent !== "function") {
|
|
70826
|
+
return body;
|
|
70827
|
+
}
|
|
70828
|
+
if (body == null) {
|
|
70829
|
+
return callOnRequestSent(handler, controller, isAborted2) ? body : requestAborted;
|
|
70830
|
+
}
|
|
70831
|
+
if (body && typeof body[Symbol.asyncIterator] === "function") {
|
|
70832
|
+
return dispatchAsyncIterableBody(body, handler, controller, isAborted2);
|
|
70833
|
+
}
|
|
70834
|
+
if (isIterableBody(body)) {
|
|
70835
|
+
const chunks = [];
|
|
70836
|
+
for (const chunk of body) {
|
|
70837
|
+
if (isAborted2()) {
|
|
70838
|
+
return requestAborted;
|
|
70839
|
+
}
|
|
70840
|
+
chunks.push(chunk);
|
|
70841
|
+
if (!callOnBodySent(handler, controller, chunk) || isAborted2()) {
|
|
70842
|
+
return requestAborted;
|
|
70843
|
+
}
|
|
70844
|
+
}
|
|
70845
|
+
return callOnRequestSent(handler, controller, isAborted2) ? chunks : requestAborted;
|
|
70846
|
+
}
|
|
70847
|
+
if (isAborted2()) {
|
|
70848
|
+
return requestAborted;
|
|
70849
|
+
}
|
|
70850
|
+
if (!callOnBodySent(handler, controller, body)) {
|
|
70851
|
+
return requestAborted;
|
|
70852
|
+
}
|
|
70853
|
+
return callOnRequestSent(handler, controller, isAborted2) ? body : requestAborted;
|
|
70854
|
+
}
|
|
70855
|
+
async function dispatchAsyncIterableBody(body, handler, controller, isAborted2) {
|
|
70856
|
+
const chunks = [];
|
|
70857
|
+
for await (const chunk of body) {
|
|
70858
|
+
if (isAborted2()) {
|
|
70859
|
+
return requestAborted;
|
|
70860
|
+
}
|
|
70861
|
+
chunks.push(chunk);
|
|
70862
|
+
if (!callOnBodySent(handler, controller, chunk) || isAborted2()) {
|
|
70863
|
+
return requestAborted;
|
|
70864
|
+
}
|
|
70865
|
+
}
|
|
70866
|
+
if (!callOnRequestSent(handler, controller, isAborted2)) {
|
|
70867
|
+
return requestAborted;
|
|
70868
|
+
}
|
|
70869
|
+
return {
|
|
70870
|
+
async *[Symbol.asyncIterator]() {
|
|
70871
|
+
yield* chunks;
|
|
70872
|
+
}
|
|
70873
|
+
};
|
|
70874
|
+
}
|
|
70875
|
+
function callOnBodySent(handler, controller, chunk) {
|
|
70876
|
+
try {
|
|
70877
|
+
handler.onBodySent?.(chunk);
|
|
70878
|
+
return true;
|
|
70879
|
+
} catch (error) {
|
|
70880
|
+
controller.abort(error);
|
|
70881
|
+
return false;
|
|
70882
|
+
}
|
|
70883
|
+
}
|
|
70884
|
+
function callOnRequestSent(handler, controller, isAborted2) {
|
|
70885
|
+
try {
|
|
70886
|
+
handler.onRequestSent?.();
|
|
70887
|
+
return !isAborted2();
|
|
70888
|
+
} catch (error) {
|
|
70889
|
+
controller.abort(error);
|
|
70890
|
+
return false;
|
|
70891
|
+
}
|
|
70892
|
+
}
|
|
70893
|
+
function isIterableBody(body) {
|
|
70894
|
+
return typeof body !== "string" && !Buffer.isBuffer(body) && !ArrayBuffer.isView(body) && typeof body[Symbol.iterator] === "function";
|
|
70895
|
+
}
|
|
70589
70896
|
function buildMockDispatch() {
|
|
70590
70897
|
const agent = this[kMockAgent];
|
|
70591
70898
|
const origin2 = this[kOrigin];
|
|
@@ -73229,15 +73536,13 @@ var require_cache = __commonJS({
|
|
|
73229
73536
|
}
|
|
73230
73537
|
}
|
|
73231
73538
|
function makeCacheKey(opts) {
|
|
73232
|
-
|
|
73233
|
-
throw new Error("opts.origin is undefined");
|
|
73234
|
-
}
|
|
73539
|
+
const origin2 = opts.origin ? opts.origin.toString() : "";
|
|
73235
73540
|
let fullPath = opts.path || "/";
|
|
73236
73541
|
if (opts.query && !pathHasQueryOrFragment(fullPath)) {
|
|
73237
73542
|
fullPath = serializePathWithQuery(fullPath, opts.query);
|
|
73238
73543
|
}
|
|
73239
73544
|
return {
|
|
73240
|
-
origin:
|
|
73545
|
+
origin: origin2,
|
|
73241
73546
|
method: opts.method,
|
|
73242
73547
|
path: fullPath,
|
|
73243
73548
|
headers: opts.headers
|
|
@@ -75320,10 +75625,13 @@ var require_cache2 = __commonJS({
|
|
|
75320
75625
|
}
|
|
75321
75626
|
return (dispatch) => {
|
|
75322
75627
|
return (opts2, handler) => {
|
|
75323
|
-
if (
|
|
75628
|
+
if (arrayIncludes(safeMethodsToNotCache, opts2.method)) {
|
|
75324
75629
|
return dispatch(opts2, handler);
|
|
75325
75630
|
}
|
|
75326
75631
|
if (origins !== void 0) {
|
|
75632
|
+
if (!opts2.origin) {
|
|
75633
|
+
return dispatch(opts2, handler);
|
|
75634
|
+
}
|
|
75327
75635
|
const requestOrigin = opts2.origin.toString().toLowerCase();
|
|
75328
75636
|
let isAllowed = false;
|
|
75329
75637
|
for (let i = 0; i < origins.length; i++) {
|
|
@@ -76021,7 +76329,7 @@ var require_deduplicate = __commonJS({
|
|
|
76021
76329
|
const pendingRequests = /* @__PURE__ */ new Map();
|
|
76022
76330
|
return (dispatch) => {
|
|
76023
76331
|
return (opts2, handler) => {
|
|
76024
|
-
if (
|
|
76332
|
+
if (opts2.upgrade || methods.includes(opts2.method) === false) {
|
|
76025
76333
|
return dispatch(opts2, handler);
|
|
76026
76334
|
}
|
|
76027
76335
|
opts2 = {
|
|
@@ -81871,6 +82179,8 @@ var require_websocket2 = __commonJS({
|
|
|
81871
82179
|
var { SendQueue } = require_sender2();
|
|
81872
82180
|
var { WebsocketFrameSend } = require_frame();
|
|
81873
82181
|
var { channels } = require_diagnostics();
|
|
82182
|
+
var kRef = /* @__PURE__ */ Symbol.for("nodejs.ref");
|
|
82183
|
+
var kUnref = /* @__PURE__ */ Symbol.for("nodejs.unref");
|
|
81874
82184
|
function getSocketAddress(socket) {
|
|
81875
82185
|
if (typeof socket?.address === "function") {
|
|
81876
82186
|
return socket.address();
|
|
@@ -81890,6 +82200,7 @@ var require_websocket2 = __commonJS({
|
|
|
81890
82200
|
#bufferedAmount = 0;
|
|
81891
82201
|
#protocol = "";
|
|
81892
82202
|
#extensions = "";
|
|
82203
|
+
#refed = true;
|
|
81893
82204
|
/** @type {SendQueue} */
|
|
81894
82205
|
#sendQueue;
|
|
81895
82206
|
/** @type {Handler} */
|
|
@@ -81972,6 +82283,16 @@ var require_websocket2 = __commonJS({
|
|
|
81972
82283
|
this.#handler.readyState = _WebSocket.CONNECTING;
|
|
81973
82284
|
this.#binaryType = "blob";
|
|
81974
82285
|
}
|
|
82286
|
+
[kRef]() {
|
|
82287
|
+
webidl.brandCheck(this, _WebSocket);
|
|
82288
|
+
this.#refed = true;
|
|
82289
|
+
this.#handler.socket?.ref?.();
|
|
82290
|
+
}
|
|
82291
|
+
[kUnref]() {
|
|
82292
|
+
webidl.brandCheck(this, _WebSocket);
|
|
82293
|
+
this.#refed = false;
|
|
82294
|
+
this.#handler.socket?.unref?.();
|
|
82295
|
+
}
|
|
81975
82296
|
/**
|
|
81976
82297
|
* @see https://websockets.spec.whatwg.org/#dom-websocket-close
|
|
81977
82298
|
* @param {number|undefined} code
|
|
@@ -82133,6 +82454,9 @@ var require_websocket2 = __commonJS({
|
|
|
82133
82454
|
*/
|
|
82134
82455
|
#onConnectionEstablished(response, parsedExtensions) {
|
|
82135
82456
|
this.#handler.socket = response.socket;
|
|
82457
|
+
if (!this.#refed) {
|
|
82458
|
+
this.#handler.socket.unref?.();
|
|
82459
|
+
}
|
|
82136
82460
|
const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments;
|
|
82137
82461
|
const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize;
|
|
82138
82462
|
const parser = new ByteParser(this.#handler, parsedExtensions, {
|