@@ -18,8 +18,10 @@ import "../_chunks/_utils.mjs"; | ||
| const res = webRes._toNodeResponse(); | ||
| writeHead(nodeRes, res.status, res.statusText, res.headers); | ||
| if (res.body) { | ||
| if (res.body instanceof ReadableStream) return streamBody(res.body, nodeRes); | ||
| else if (typeof res.body?.pipe === "function") return pipeBody(res.body, nodeRes); | ||
| if (res.body instanceof ReadableStream) { | ||
| writeHead(nodeRes, res.status, res.statusText, res.headers); | ||
| return streamBody(res.body, nodeRes); | ||
| } else if (typeof res.body?.pipe === "function") return pipeBody(res.body, nodeRes, res.status, res.statusText, res.headers); | ||
| writeHead(nodeRes, res.status, res.statusText, res.headers); | ||
| nodeRes.write(res.body); | ||
| } | ||
| } else writeHead(nodeRes, res.status, res.statusText, res.headers); | ||
| return endNodeResponse(nodeRes); | ||
@@ -39,3 +41,3 @@ } | ||
| } | ||
| function pipeBody(stream, nodeRes) { | ||
| function pipeBody(stream, nodeRes, status, statusText, headers) { | ||
| if (nodeRes.destroyed) { | ||
@@ -45,5 +47,30 @@ stream.destroy?.(); | ||
| } | ||
| if (typeof stream.on === "function" && typeof stream.destroy === "function") return pipeline(stream, nodeRes).catch(() => {}); | ||
| stream.pipe(nodeRes); | ||
| return new Promise((resolve) => nodeRes.on("close", resolve)); | ||
| if (typeof stream.on !== "function" || typeof stream.destroy !== "function") { | ||
| writeHead(nodeRes, status, statusText, headers); | ||
| stream.pipe(nodeRes); | ||
| return new Promise((resolve) => nodeRes.on("close", resolve)); | ||
| } | ||
| if (stream.destroyed) { | ||
| writeHead(nodeRes, 500, "Internal Server Error", []); | ||
| return endNodeResponse(nodeRes); | ||
| } | ||
| return new Promise((resolve) => { | ||
| function onEarlyError() { | ||
| stream.off("readable", onReadable); | ||
| stream.destroy(); | ||
| writeHead(nodeRes, 500, "Internal Server Error", []); | ||
| endNodeResponse(nodeRes).then(resolve); | ||
| } | ||
| function onReadable() { | ||
| stream.off("error", onEarlyError); | ||
| if (nodeRes.destroyed) { | ||
| stream.destroy(); | ||
| return resolve(); | ||
| } | ||
| writeHead(nodeRes, status, statusText, headers); | ||
| pipeline(stream, nodeRes).catch(() => {}).then(() => resolve()); | ||
| } | ||
| stream.once("error", onEarlyError); | ||
| stream.once("readable", onReadable); | ||
| }); | ||
| } | ||
@@ -50,0 +77,0 @@ function streamBody(stream, nodeRes) { |
+1
-1
@@ -187,3 +187,3 @@ import { a as green, c as url, i as gray, l as yellow, n as bold, o as magenta, r as cyan, s as red } from "./_chunks/_utils.mjs"; | ||
| name: "srvx", | ||
| version: "0.11.10", | ||
| version: "0.11.11", | ||
| description: "Universal Server." | ||
@@ -190,0 +190,0 @@ }; |
+1
-1
| { | ||
| "name": "srvx", | ||
| "version": "0.11.11", | ||
| "version": "0.11.12", | ||
| "description": "Universal Server.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://srvx.h3.dev", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
116560
0.79%2582
1.06%