Files
scriptc/tests/fixtures/server/cases/http-trailers/limit-driver.mjs
Chris Tate c8b42772a8 fix(http): enforce HTTP/1.1 Host requirement (#388)
* 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.
2026-09-23 10:21:53 -05:00

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");