mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-24 06:14:01 +08:00
* fix(http): enforce HTTP/1.1 Host requirement - Enforce Node's default Host behavior while preserving opt-out and HTTP/1.0 handling. - Match the 400 wire response and add C/LLVM differential coverage. * feat(http): add static HTTP trailer and streaming support - Parse incoming chunk trailers and expose distinct/raw trailer reads. - Frame outgoing trailers and add streaming controls with differential coverage. * fix(http): harden request trailer parsing - Safely discard trailers after early responses while preserving parser validation. - Bound aggregate head and trailer parsing by bytes and field count. - Add regressions for early response trailers and overflow rejection.
28 lines
855 B
JavaScript
28 lines
855 B
JavaScript
import { connect } from "node:net";
|
|
|
|
const port = Number(process.argv[2]);
|
|
|
|
function exchange(wire) {
|
|
return new Promise((resolve, reject) => {
|
|
let response = "";
|
|
const socket = connect(port, "127.0.0.1", () => socket.end(wire));
|
|
socket.on("data", (chunk) => { response += chunk.toString("latin1"); });
|
|
socket.on("end", () => resolve(response));
|
|
socket.on("error", reject);
|
|
socket.setTimeout(5000, () => reject(new Error("timeout")));
|
|
});
|
|
}
|
|
|
|
const overflow = await exchange(
|
|
"POST /limit HTTP/1.1\r\n" +
|
|
"Host: test\r\n" +
|
|
"Connection: close\r\n" +
|
|
"Transfer-Encoding: chunked\r\n\r\n" +
|
|
"0\r\n" +
|
|
"X: y\r\n".repeat(1001) +
|
|
"\r\n",
|
|
);
|
|
console.log(`limit ${overflow.split("\r\n")[0]}`);
|
|
await exchange("GET /quit HTTP/1.1\r\nHost: test\r\nConnection: close\r\n\r\n");
|
|
console.log("limit driver done");
|