Files
scriptc/tests/corpus/2973-http-static-agent.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

23 lines
1021 B
TypeScript

import { Agent, createServer, request } from "node:http";
const agent = new Agent({ maxSockets: 1 });
console.log("agent defaults", agent.getName(), agent.maxSockets, agent.maxFreeSockets, agent.keepAlive, agent.protocol);
console.log("agent name", agent.getName({ host: "example.test", port: 8080, family: 4 }));
const server = createServer((req, res) => { res.end(req.url); });
server.listen(0, () => {
const port = server.address().port;
const name = agent.getName({ host: "127.0.0.1", port });
const outbound = request({ hostname: "127.0.0.1", port, path: "/agent", agent }, (response) => {
console.log("agent tables", agent.sockets[name].length, name in agent.requests, Object.keys(agent.freeSockets).length);
let body = "";
response.on("data", (chunk: Buffer) => { body += chunk.toString("utf8"); });
response.on("end", () => {
console.log("response", response.statusCode, body, agent.totalSocketCount);
agent.destroy();
server.close();
});
});
outbound.end();
});