mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-16 05:00:59 +08:00
* feat(http): materialize static distinct header snapshots - Preserve precise string array types for whole incoming header and trailer collections. - Cover duplicate headers, trailers, and raw header reads against Node in both backends. - Refresh test-backed static HTTP compatibility claims. * feat(http): expand the static Node HTTP surface - Add HTTP module values, request and response lifecycle state, and socket controls. - Implement server timeout and connection shutdown behavior in the native runtime. - Cover C and LLVM behavior with Node differential fixtures, refresh compatibility evidence, and recover interrupted Sandbox streams. * fix(http): honor message timeout handlers - Keep server sockets open when request or response timeout listeners handle the event. - Add differential regressions and refresh the TypeScript 7 order baseline.
29 lines
975 B
TypeScript
29 lines
975 B
TypeScript
import * as http from "node:http";
|
|
|
|
function result(action: () => void): string {
|
|
try {
|
|
action();
|
|
return "ok";
|
|
} catch (error) {
|
|
if (error instanceof Error) return `${error.name}:${(error as NodeJS.ErrnoException).code}:${error.message}`;
|
|
return "unexpected error";
|
|
}
|
|
}
|
|
|
|
const server = http.createServer((incoming, outgoing) => {
|
|
console.log("message negative", result(() => incoming.setTimeout(-1)));
|
|
console.log("message infinite", result(() => incoming.setTimeout(Infinity, () => {})));
|
|
incoming.resume();
|
|
outgoing.end("ok");
|
|
});
|
|
|
|
server.listen(0, "127.0.0.1", () => {
|
|
const client = http.request({ host: "127.0.0.1", port: server.address().port, method: "POST" }, (response) => {
|
|
response.resume();
|
|
response.on("end", () => server.close());
|
|
});
|
|
console.log("client negative", result(() => client.setTimeout(-1)));
|
|
console.log("client infinite", result(() => client.setTimeout(Infinity, () => {})));
|
|
client.end("ping");
|
|
});
|