This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
export { }
export { }
+1 -1
View File
@@ -1,2 +1,2 @@
export { }
export { }
+73 -3
View File
@@ -190,6 +190,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
@@ -296,6 +307,17 @@ var Response2 = class _Response {
}
});
});
Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response2, GlobalResponse);
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
@@ -376,6 +398,50 @@ if (typeof global.crypto === "undefined") {
// src/listener.ts
var outgoingEnded = Symbol("outgoingEnded");
var incomingDraining = Symbol("incomingDraining");
var DRAIN_TIMEOUT_MS = 500;
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
var drainIncoming = (incoming) => {
const incomingWithDrainState = incoming;
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
return;
}
incomingWithDrainState[incomingDraining] = true;
if (incoming instanceof import_node_http22.Http2ServerRequest) {
try {
;
incoming.stream?.close?.(import_node_http22.constants.NGHTTP2_NO_ERROR);
} catch {
}
return;
}
let bytesRead = 0;
const cleanup = () => {
clearTimeout(timer);
incoming.off("data", onData);
incoming.off("end", cleanup);
incoming.off("error", cleanup);
};
const forceClose = () => {
cleanup();
const socket = incoming.socket;
if (socket && !socket.destroyed) {
socket.destroySoon();
}
};
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
timer.unref?.();
const onData = (chunk) => {
bytesRead += chunk.length;
if (bytesRead > MAX_DRAIN_BYTES) {
forceClose();
}
};
incoming.on("data", onData);
incoming.on("end", cleanup);
incoming.on("error", cleanup);
incoming.resume();
};
var handleRequestError = () => new Response(null, {
status: 400
});
@@ -547,14 +613,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
outgoing.destroy();
drainIncoming(incoming);
});
}
});
}
};
}
outgoing.on("finish", () => {
if (!incomingEnded) {
drainIncoming(incoming);
}
});
}
outgoing.on("close", () => {
const abortController = req[abortControllerKey];
@@ -569,7 +639,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
drainIncoming(incoming);
});
}
});
+74 -4
View File
@@ -2,7 +2,7 @@
import { createServer as createServerHTTP } from "http";
// src/listener.ts
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
// src/request.ts
import { Http2ServerRequest } from "http2";
@@ -151,6 +151,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
@@ -257,6 +268,17 @@ var Response2 = class _Response {
}
});
});
Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response2, GlobalResponse);
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
@@ -337,6 +359,50 @@ if (typeof global.crypto === "undefined") {
// src/listener.ts
var outgoingEnded = Symbol("outgoingEnded");
var incomingDraining = Symbol("incomingDraining");
var DRAIN_TIMEOUT_MS = 500;
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
var drainIncoming = (incoming) => {
const incomingWithDrainState = incoming;
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
return;
}
incomingWithDrainState[incomingDraining] = true;
if (incoming instanceof Http2ServerRequest2) {
try {
;
incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
} catch {
}
return;
}
let bytesRead = 0;
const cleanup = () => {
clearTimeout(timer);
incoming.off("data", onData);
incoming.off("end", cleanup);
incoming.off("error", cleanup);
};
const forceClose = () => {
cleanup();
const socket = incoming.socket;
if (socket && !socket.destroyed) {
socket.destroySoon();
}
};
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
timer.unref?.();
const onData = (chunk) => {
bytesRead += chunk.length;
if (bytesRead > MAX_DRAIN_BYTES) {
forceClose();
}
};
incoming.on("data", onData);
incoming.on("end", cleanup);
incoming.on("error", cleanup);
incoming.resume();
};
var handleRequestError = () => new Response(null, {
status: 400
});
@@ -508,14 +574,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
outgoing.destroy();
drainIncoming(incoming);
});
}
});
}
};
}
outgoing.on("finish", () => {
if (!incomingEnded) {
drainIncoming(incoming);
}
});
}
outgoing.on("close", () => {
const abortController = req[abortControllerKey];
@@ -530,7 +600,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
drainIncoming(incoming);
});
}
});
+73 -3
View File
@@ -182,6 +182,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
@@ -288,6 +299,17 @@ var Response2 = class _Response {
}
});
});
Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response2, GlobalResponse);
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
@@ -368,6 +390,50 @@ if (typeof global.crypto === "undefined") {
// src/listener.ts
var outgoingEnded = Symbol("outgoingEnded");
var incomingDraining = Symbol("incomingDraining");
var DRAIN_TIMEOUT_MS = 500;
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
var drainIncoming = (incoming) => {
const incomingWithDrainState = incoming;
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
return;
}
incomingWithDrainState[incomingDraining] = true;
if (incoming instanceof import_node_http22.Http2ServerRequest) {
try {
;
incoming.stream?.close?.(import_node_http22.constants.NGHTTP2_NO_ERROR);
} catch {
}
return;
}
let bytesRead = 0;
const cleanup = () => {
clearTimeout(timer);
incoming.off("data", onData);
incoming.off("end", cleanup);
incoming.off("error", cleanup);
};
const forceClose = () => {
cleanup();
const socket = incoming.socket;
if (socket && !socket.destroyed) {
socket.destroySoon();
}
};
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
timer.unref?.();
const onData = (chunk) => {
bytesRead += chunk.length;
if (bytesRead > MAX_DRAIN_BYTES) {
forceClose();
}
};
incoming.on("data", onData);
incoming.on("end", cleanup);
incoming.on("error", cleanup);
incoming.resume();
};
var handleRequestError = () => new Response(null, {
status: 400
});
@@ -539,14 +605,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
outgoing.destroy();
drainIncoming(incoming);
});
}
});
}
};
}
outgoing.on("finish", () => {
if (!incomingEnded) {
drainIncoming(incoming);
}
});
}
outgoing.on("close", () => {
const abortController = req[abortControllerKey];
@@ -561,7 +631,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
drainIncoming(incoming);
});
}
});
+74 -4
View File
@@ -1,5 +1,5 @@
// src/listener.ts
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
// src/request.ts
import { Http2ServerRequest } from "http2";
@@ -148,6 +148,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
@@ -254,6 +265,17 @@ var Response2 = class _Response {
}
});
});
Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response2, GlobalResponse);
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
@@ -334,6 +356,50 @@ if (typeof global.crypto === "undefined") {
// src/listener.ts
var outgoingEnded = Symbol("outgoingEnded");
var incomingDraining = Symbol("incomingDraining");
var DRAIN_TIMEOUT_MS = 500;
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
var drainIncoming = (incoming) => {
const incomingWithDrainState = incoming;
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
return;
}
incomingWithDrainState[incomingDraining] = true;
if (incoming instanceof Http2ServerRequest2) {
try {
;
incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
} catch {
}
return;
}
let bytesRead = 0;
const cleanup = () => {
clearTimeout(timer);
incoming.off("data", onData);
incoming.off("end", cleanup);
incoming.off("error", cleanup);
};
const forceClose = () => {
cleanup();
const socket = incoming.socket;
if (socket && !socket.destroyed) {
socket.destroySoon();
}
};
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
timer.unref?.();
const onData = (chunk) => {
bytesRead += chunk.length;
if (bytesRead > MAX_DRAIN_BYTES) {
forceClose();
}
};
incoming.on("data", onData);
incoming.on("end", cleanup);
incoming.on("error", cleanup);
incoming.resume();
};
var handleRequestError = () => new Response(null, {
status: 400
});
@@ -505,14 +571,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
outgoing.destroy();
drainIncoming(incoming);
});
}
});
}
};
}
outgoing.on("finish", () => {
if (!incomingEnded) {
drainIncoming(incoming);
}
});
}
outgoing.on("close", () => {
const abortController = req[abortControllerKey];
@@ -527,7 +597,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
drainIncoming(incoming);
});
}
});
+1 -1
View File
@@ -22,4 +22,4 @@ declare const abortControllerKey: unique symbol;
declare const getAbortController: unique symbol;
declare const newRequest: (incoming: IncomingMessage | Http2ServerRequest, defaultHostname?: string) => any;
export { GlobalRequest, IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
export { GlobalRequest, type IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
+1 -1
View File
@@ -22,4 +22,4 @@ declare const abortControllerKey: unique symbol;
declare const getAbortController: unique symbol;
declare const newRequest: (incoming: IncomingMessage | Http2ServerRequest, defaultHostname?: string) => any;
export { GlobalRequest, IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
export { GlobalRequest, type IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
+11
View File
@@ -176,6 +176,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
+11
View File
@@ -145,6 +145,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
+1 -1
View File
@@ -23,4 +23,4 @@ declare class Response {
get ok(): boolean;
}
export { GlobalResponse, InternalCache, Response, cacheKey };
export { GlobalResponse, type InternalCache, Response, cacheKey };
+1 -1
View File
@@ -23,4 +23,4 @@ declare class Response {
get ok(): boolean;
}
export { GlobalResponse, InternalCache, Response, cacheKey };
export { GlobalResponse, type InternalCache, Response, cacheKey };
+11
View File
@@ -91,6 +91,17 @@ var Response = class _Response {
}
});
});
Object.defineProperty(Response.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response, GlobalResponse);
Object.setPrototypeOf(Response.prototype, GlobalResponse.prototype);
// Annotate the CommonJS export names for ESM import in node:
+11
View File
@@ -65,6 +65,17 @@ var Response = class _Response {
}
});
});
Object.defineProperty(Response.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response, GlobalResponse);
Object.setPrototypeOf(Response.prototype, GlobalResponse.prototype);
export {
+1 -1
View File
@@ -14,4 +14,4 @@ type ServeStaticOptions<E extends Env = Env> = {
};
declare const serveStatic: <E extends Env = any>(options?: ServeStaticOptions<E>) => MiddlewareHandler<E>;
export { ServeStaticOptions, serveStatic };
export { type ServeStaticOptions, serveStatic };
+1 -1
View File
@@ -14,4 +14,4 @@ type ServeStaticOptions<E extends Env = Env> = {
};
declare const serveStatic: <E extends Env = any>(options?: ServeStaticOptions<E>) => MiddlewareHandler<E>;
export { ServeStaticOptions, serveStatic };
export { type ServeStaticOptions, serveStatic };
+1 -1
View File
@@ -100,7 +100,7 @@ var serveStatic = (options = { root: "" }) => {
} else {
try {
filename = tryDecodeURI(c.req.path);
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) {
throw new Error();
}
} catch {
+1 -1
View File
@@ -76,7 +76,7 @@ var serveStatic = (options = { root: "" }) => {
} else {
try {
filename = tryDecodeURI(c.req.path);
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) {
throw new Error();
}
} catch {
+73 -3
View File
@@ -186,6 +186,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
@@ -292,6 +303,17 @@ var Response2 = class _Response {
}
});
});
Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response2, GlobalResponse);
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
@@ -372,6 +394,50 @@ if (typeof global.crypto === "undefined") {
// src/listener.ts
var outgoingEnded = Symbol("outgoingEnded");
var incomingDraining = Symbol("incomingDraining");
var DRAIN_TIMEOUT_MS = 500;
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
var drainIncoming = (incoming) => {
const incomingWithDrainState = incoming;
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
return;
}
incomingWithDrainState[incomingDraining] = true;
if (incoming instanceof import_node_http22.Http2ServerRequest) {
try {
;
incoming.stream?.close?.(import_node_http22.constants.NGHTTP2_NO_ERROR);
} catch {
}
return;
}
let bytesRead = 0;
const cleanup = () => {
clearTimeout(timer);
incoming.off("data", onData);
incoming.off("end", cleanup);
incoming.off("error", cleanup);
};
const forceClose = () => {
cleanup();
const socket = incoming.socket;
if (socket && !socket.destroyed) {
socket.destroySoon();
}
};
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
timer.unref?.();
const onData = (chunk) => {
bytesRead += chunk.length;
if (bytesRead > MAX_DRAIN_BYTES) {
forceClose();
}
};
incoming.on("data", onData);
incoming.on("end", cleanup);
incoming.on("error", cleanup);
incoming.resume();
};
var handleRequestError = () => new Response(null, {
status: 400
});
@@ -543,14 +609,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
outgoing.destroy();
drainIncoming(incoming);
});
}
});
}
};
}
outgoing.on("finish", () => {
if (!incomingEnded) {
drainIncoming(incoming);
}
});
}
outgoing.on("close", () => {
const abortController = req[abortControllerKey];
@@ -565,7 +635,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
drainIncoming(incoming);
});
}
});
+74 -4
View File
@@ -2,7 +2,7 @@
import { createServer as createServerHTTP } from "http";
// src/listener.ts
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
// src/request.ts
import { Http2ServerRequest } from "http2";
@@ -151,6 +151,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
@@ -257,6 +268,17 @@ var Response2 = class _Response {
}
});
});
Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response2, GlobalResponse);
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
@@ -337,6 +359,50 @@ if (typeof global.crypto === "undefined") {
// src/listener.ts
var outgoingEnded = Symbol("outgoingEnded");
var incomingDraining = Symbol("incomingDraining");
var DRAIN_TIMEOUT_MS = 500;
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
var drainIncoming = (incoming) => {
const incomingWithDrainState = incoming;
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
return;
}
incomingWithDrainState[incomingDraining] = true;
if (incoming instanceof Http2ServerRequest2) {
try {
;
incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
} catch {
}
return;
}
let bytesRead = 0;
const cleanup = () => {
clearTimeout(timer);
incoming.off("data", onData);
incoming.off("end", cleanup);
incoming.off("error", cleanup);
};
const forceClose = () => {
cleanup();
const socket = incoming.socket;
if (socket && !socket.destroyed) {
socket.destroySoon();
}
};
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
timer.unref?.();
const onData = (chunk) => {
bytesRead += chunk.length;
if (bytesRead > MAX_DRAIN_BYTES) {
forceClose();
}
};
incoming.on("data", onData);
incoming.on("end", cleanup);
incoming.on("error", cleanup);
incoming.resume();
};
var handleRequestError = () => new Response(null, {
status: 400
});
@@ -508,14 +574,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
outgoing.destroy();
drainIncoming(incoming);
});
}
});
}
};
}
outgoing.on("finish", () => {
if (!incomingEnded) {
drainIncoming(incoming);
}
});
}
outgoing.on("close", () => {
const abortController = req[abortControllerKey];
@@ -530,7 +600,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
drainIncoming(incoming);
});
}
});
+3 -3
View File
@@ -1,5 +1,5 @@
import { IncomingMessage, ServerResponse, Server, ServerOptions as ServerOptions$1, createServer } from 'node:http';
import { Http2ServerRequest, Http2ServerResponse, Http2Server, Http2SecureServer, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
import { IncomingMessage, ServerResponse, ServerOptions as ServerOptions$1, createServer, Server } from 'node:http';
import { Http2ServerRequest, Http2ServerResponse, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer, Http2Server, Http2SecureServer } from 'node:http2';
import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https';
type HttpBindings = {
@@ -41,4 +41,4 @@ type Options = {
} & ServerOptions;
type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>;
export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
export type { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
+3 -3
View File
@@ -1,5 +1,5 @@
import { IncomingMessage, ServerResponse, Server, ServerOptions as ServerOptions$1, createServer } from 'node:http';
import { Http2ServerRequest, Http2ServerResponse, Http2Server, Http2SecureServer, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
import { IncomingMessage, ServerResponse, ServerOptions as ServerOptions$1, createServer, Server } from 'node:http';
import { Http2ServerRequest, Http2ServerResponse, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer, Http2Server, Http2SecureServer } from 'node:http2';
import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https';
type HttpBindings = {
@@ -41,4 +41,4 @@ type Options = {
} & ServerOptions;
type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>;
export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
export type { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
+2 -2
View File
@@ -2,8 +2,8 @@ import { OutgoingHttpHeaders } from 'node:http';
import { Writable } from 'node:stream';
declare function readWithoutBlocking(readPromise: Promise<ReadableStreamReadResult<Uint8Array>>): Promise<ReadableStreamReadResult<Uint8Array> | undefined>;
declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<void>;
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<void> | undefined;
declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<undefined>;
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined;
declare const buildOutgoingHttpHeaders: (headers: Headers | HeadersInit | null | undefined) => OutgoingHttpHeaders;
export { buildOutgoingHttpHeaders, readWithoutBlocking, writeFromReadableStream, writeFromReadableStreamDefaultReader };
+2 -2
View File
@@ -2,8 +2,8 @@ import { OutgoingHttpHeaders } from 'node:http';
import { Writable } from 'node:stream';
declare function readWithoutBlocking(readPromise: Promise<ReadableStreamReadResult<Uint8Array>>): Promise<ReadableStreamReadResult<Uint8Array> | undefined>;
declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<void>;
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<void> | undefined;
declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<undefined>;
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined;
declare const buildOutgoingHttpHeaders: (headers: Headers | HeadersInit | null | undefined) => OutgoingHttpHeaders;
export { buildOutgoingHttpHeaders, readWithoutBlocking, writeFromReadableStream, writeFromReadableStreamDefaultReader };
+73 -3
View File
@@ -184,6 +184,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
@@ -290,6 +301,17 @@ var Response2 = class _Response {
}
});
});
Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response2, GlobalResponse);
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
@@ -370,6 +392,50 @@ if (typeof global.crypto === "undefined") {
// src/listener.ts
var outgoingEnded = Symbol("outgoingEnded");
var incomingDraining = Symbol("incomingDraining");
var DRAIN_TIMEOUT_MS = 500;
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
var drainIncoming = (incoming) => {
const incomingWithDrainState = incoming;
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
return;
}
incomingWithDrainState[incomingDraining] = true;
if (incoming instanceof import_node_http22.Http2ServerRequest) {
try {
;
incoming.stream?.close?.(import_node_http22.constants.NGHTTP2_NO_ERROR);
} catch {
}
return;
}
let bytesRead = 0;
const cleanup = () => {
clearTimeout(timer);
incoming.off("data", onData);
incoming.off("end", cleanup);
incoming.off("error", cleanup);
};
const forceClose = () => {
cleanup();
const socket = incoming.socket;
if (socket && !socket.destroyed) {
socket.destroySoon();
}
};
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
timer.unref?.();
const onData = (chunk) => {
bytesRead += chunk.length;
if (bytesRead > MAX_DRAIN_BYTES) {
forceClose();
}
};
incoming.on("data", onData);
incoming.on("end", cleanup);
incoming.on("error", cleanup);
incoming.resume();
};
var handleRequestError = () => new Response(null, {
status: 400
});
@@ -541,14 +607,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
outgoing.destroy();
drainIncoming(incoming);
});
}
});
}
};
}
outgoing.on("finish", () => {
if (!incomingEnded) {
drainIncoming(incoming);
}
});
}
outgoing.on("close", () => {
const abortController = req[abortControllerKey];
@@ -563,7 +633,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
drainIncoming(incoming);
});
}
});
+74 -4
View File
@@ -1,5 +1,5 @@
// src/listener.ts
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
// src/request.ts
import { Http2ServerRequest } from "http2";
@@ -148,6 +148,17 @@ var requestPrototype = {
}
});
});
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
method: this.method,
url: this.url,
headers: this.headers,
nativeRequest: this[requestCache]
};
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(requestPrototype, Request.prototype);
var newRequest = (incoming, defaultHostname) => {
const req = Object.create(requestPrototype);
@@ -254,6 +265,17 @@ var Response2 = class _Response {
}
});
});
Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
value: function(depth, options, inspectFn) {
const props = {
status: this.status,
headers: this.headers,
ok: this.ok,
nativeResponse: this[responseCache]
};
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
}
});
Object.setPrototypeOf(Response2, GlobalResponse);
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
@@ -334,6 +356,50 @@ if (typeof global.crypto === "undefined") {
// src/listener.ts
var outgoingEnded = Symbol("outgoingEnded");
var incomingDraining = Symbol("incomingDraining");
var DRAIN_TIMEOUT_MS = 500;
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
var drainIncoming = (incoming) => {
const incomingWithDrainState = incoming;
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
return;
}
incomingWithDrainState[incomingDraining] = true;
if (incoming instanceof Http2ServerRequest2) {
try {
;
incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
} catch {
}
return;
}
let bytesRead = 0;
const cleanup = () => {
clearTimeout(timer);
incoming.off("data", onData);
incoming.off("end", cleanup);
incoming.off("error", cleanup);
};
const forceClose = () => {
cleanup();
const socket = incoming.socket;
if (socket && !socket.destroyed) {
socket.destroySoon();
}
};
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
timer.unref?.();
const onData = (chunk) => {
bytesRead += chunk.length;
if (bytesRead > MAX_DRAIN_BYTES) {
forceClose();
}
};
incoming.on("data", onData);
incoming.on("end", cleanup);
incoming.on("error", cleanup);
incoming.resume();
};
var handleRequestError = () => new Response(null, {
status: 400
});
@@ -505,14 +571,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
outgoing.destroy();
drainIncoming(incoming);
});
}
});
}
};
}
outgoing.on("finish", () => {
if (!incomingEnded) {
drainIncoming(incoming);
}
});
}
outgoing.on("close", () => {
const abortController = req[abortControllerKey];
@@ -527,7 +597,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
setTimeout(() => {
if (!incomingEnded) {
setTimeout(() => {
incoming.destroy();
drainIncoming(incoming);
});
}
});