@hono/node-server
Advanced tools
Comparing version 1.13.7 to 1.13.8
@@ -97,3 +97,12 @@ "use strict"; | ||
if (!(method === "GET" || method === "HEAD")) { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) { | ||
init.body = new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue(incoming.rawBody); | ||
controller.close(); | ||
} | ||
}); | ||
} else { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
} | ||
} | ||
@@ -446,6 +455,10 @@ return new Request(url, init); | ||
outgoing.on("close", () => { | ||
const abortController = req[abortControllerKey]; | ||
if (!abortController) { | ||
return; | ||
} | ||
if (incoming.errored) { | ||
req[getAbortController]().abort(incoming.errored.toString()); | ||
req[abortControllerKey].abort(incoming.errored.toString()); | ||
} else if (!outgoing.writableFinished) { | ||
req[getAbortController]().abort("Client connection prematurely closed."); | ||
req[abortControllerKey].abort("Client connection prematurely closed."); | ||
} | ||
@@ -452,0 +465,0 @@ }); |
@@ -91,3 +91,12 @@ "use strict"; | ||
if (!(method === "GET" || method === "HEAD")) { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) { | ||
init.body = new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue(incoming.rawBody); | ||
controller.close(); | ||
} | ||
}); | ||
} else { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
} | ||
} | ||
@@ -440,6 +449,10 @@ return new Request(url, init); | ||
outgoing.on("close", () => { | ||
const abortController = req[abortControllerKey]; | ||
if (!abortController) { | ||
return; | ||
} | ||
if (incoming.errored) { | ||
req[getAbortController]().abort(incoming.errored.toString()); | ||
req[abortControllerKey].abort(incoming.errored.toString()); | ||
} else if (!outgoing.writableFinished) { | ||
req[getAbortController]().abort("Client connection prematurely closed."); | ||
req[abortControllerKey].abort("Client connection prematurely closed."); | ||
} | ||
@@ -446,0 +459,0 @@ }); |
@@ -18,5 +18,6 @@ import { IncomingMessage } from 'node:http'; | ||
} | ||
declare const abortControllerKey: unique symbol; | ||
declare const getAbortController: unique symbol; | ||
declare const newRequest: (incoming: IncomingMessage | Http2ServerRequest, defaultHostname?: string) => any; | ||
export { GlobalRequest, Request, RequestError, getAbortController, newRequest, toRequestError }; | ||
export { GlobalRequest, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError }; |
@@ -26,2 +26,3 @@ "use strict"; | ||
RequestError: () => RequestError, | ||
abortControllerKey: () => abortControllerKey, | ||
getAbortController: () => getAbortController, | ||
@@ -85,3 +86,12 @@ newRequest: () => newRequest, | ||
if (!(method === "GET" || method === "HEAD")) { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) { | ||
init.body = new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue(incoming.rawBody); | ||
controller.close(); | ||
} | ||
}); | ||
} else { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
} | ||
} | ||
@@ -167,2 +177,3 @@ return new Request(url, init); | ||
RequestError, | ||
abortControllerKey, | ||
getAbortController, | ||
@@ -169,0 +180,0 @@ newRequest, |
@@ -93,3 +93,12 @@ "use strict"; | ||
if (!(method === "GET" || method === "HEAD")) { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) { | ||
init.body = new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue(incoming.rawBody); | ||
controller.close(); | ||
} | ||
}); | ||
} else { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
} | ||
} | ||
@@ -442,6 +451,10 @@ return new Request(url, init); | ||
outgoing.on("close", () => { | ||
const abortController = req[abortControllerKey]; | ||
if (!abortController) { | ||
return; | ||
} | ||
if (incoming.errored) { | ||
req[getAbortController]().abort(incoming.errored.toString()); | ||
req[abortControllerKey].abort(incoming.errored.toString()); | ||
} else if (!outgoing.writableFinished) { | ||
req[getAbortController]().abort("Client connection prematurely closed."); | ||
req[abortControllerKey].abort("Client connection prematurely closed."); | ||
} | ||
@@ -448,0 +461,0 @@ }); |
@@ -43,2 +43,2 @@ import { IncomingMessage, ServerResponse, Server, ServerOptions as ServerOptions$1, createServer } from 'node:http'; | ||
export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerType }; | ||
export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType }; |
@@ -91,3 +91,12 @@ "use strict"; | ||
if (!(method === "GET" || method === "HEAD")) { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) { | ||
init.body = new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue(incoming.rawBody); | ||
controller.close(); | ||
} | ||
}); | ||
} else { | ||
init.body = import_node_stream.Readable.toWeb(incoming); | ||
} | ||
} | ||
@@ -440,6 +449,10 @@ return new Request(url, init); | ||
outgoing.on("close", () => { | ||
const abortController = req[abortControllerKey]; | ||
if (!abortController) { | ||
return; | ||
} | ||
if (incoming.errored) { | ||
req[getAbortController]().abort(incoming.errored.toString()); | ||
req[abortControllerKey].abort(incoming.errored.toString()); | ||
} else if (!outgoing.writableFinished) { | ||
req[getAbortController]().abort("Client connection prematurely closed."); | ||
req[abortControllerKey].abort("Client connection prematurely closed."); | ||
} | ||
@@ -446,0 +459,0 @@ }); |
{ | ||
"name": "@hono/node-server", | ||
"version": "1.13.7", | ||
"version": "1.13.8", | ||
"description": "Node.js Adapter for Hono", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
172245
5159