Files
scriptc/tests/corpus/2986-http-static-client-socket-finish.ts
Chris Tate 0b8b5d5bf7 feat(http): expand the static Node HTTP surface (#410)
* 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.
2026-09-24 23:39:09 -05:00

27 lines
1.0 KiB
TypeScript

import * as http from "node:http";
const server = http.createServer((incoming, outgoing) => {
incoming.resume();
incoming.on("end", () => outgoing.end("ok"));
});
server.listen(0, "127.0.0.1", () => {
const outbound = http.request({ host: "127.0.0.1", port: server.address().port, method: "POST" }, (response) => {
response.resume();
response.on("end", () => server.close());
});
console.log("initial", outbound.socket === outbound.connection, outbound.writableFinished, outbound.destroyed);
outbound.on("socket", (socket) => {
console.log("socket", socket === outbound.socket, socket.destroyed, outbound.writableFinished);
});
outbound.once("socket", () => console.log("socket once"));
outbound.once("finish", () => {
console.log("finish", outbound.writableEnded, outbound.writableFinished, outbound.destroyed);
});
outbound.on("close", () => {
console.log("close", outbound.writableFinished, outbound.destroyed);
});
outbound.end("hi");
console.log("ended", outbound.writableEnded, outbound.writableFinished);
});