1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

fix(ext/node): add ClientRequest#setNoDelay (#21694)

Fixes https://github.com/denoland/deno/issues/18316
This commit is contained in:
Divy Srivastava 2023-12-25 08:58:51 +05:30 committed by GitHub
parent 8702894feb
commit 60da9d493c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -584,6 +584,27 @@ Deno.test("[node/http] ClientRequest setTimeout", async () => {
assertEquals(body, "HTTP/1.1");
});
Deno.test("[node/http] ClientRequest setNoDelay", async () => {
let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>();
const timer = setTimeout(() => reject("timed out"), 50000);
const req = http.request("http://localhost:4545/http_version", (resp) => {
resp.on("data", (chunk) => {
body += chunk;
});
resp.on("end", () => {
resolve();
});
});
req.setNoDelay(true);
req.once("error", (e) => reject(e));
req.end();
await promise;
clearTimeout(timer);
assertEquals(body, "HTTP/1.1");
});
Deno.test("[node/http] ClientRequest PATCH", async () => {
let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>();

View file

@ -892,6 +892,11 @@ class ClientRequest extends OutgoingMessage {
}
headers.push([key, value]);
}
// Once a socket is assigned to this request and is connected socket.setNoDelay() will be called.
setNoDelay() {
this.socket?.setNoDelay?.();
}
}
// isCookieField performs a case-insensitive comparison of a provided string