mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-20 05:40:17 +08:00
- Lower the HTTPS options row through the runtime ABI with callback ownership and loop liveness. - Pin HTTP and HTTPS response callbacks with differential and tier-regression coverage. Co-authored-by: morler <478444+morler@users.noreply.github.com>
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
// The options-object response callback is part of request(), not just the
|
|
// URL-string row. Exercise both clients against a released local port: the
|
|
// callback must compile even though connection refusal keeps it from firing.
|
|
import * as net from "node:net";
|
|
import * as http from "node:http";
|
|
import * as https from "node:https";
|
|
|
|
const probe = net.createServer();
|
|
probe.listen(0, () => {
|
|
const port = probe.address().port;
|
|
probe.close(() => {
|
|
const plain = http.request(
|
|
{ hostname: "127.0.0.1", port, path: "/", method: "GET" },
|
|
() => console.log("unexpected http response"),
|
|
);
|
|
plain.on("error", () => console.log("http refused"));
|
|
plain.on("close", () => {
|
|
const secure = https.request(
|
|
{
|
|
hostname: "127.0.0.1",
|
|
port,
|
|
path: "/",
|
|
method: "GET",
|
|
rejectUnauthorized: false,
|
|
},
|
|
() => console.log("unexpected https response"),
|
|
);
|
|
secure.on("error", () => console.log("https refused"));
|
|
secure.end();
|
|
});
|
|
plain.end();
|
|
});
|
|
});
|