mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(ext/node): add ClientRequest#setNoDelay (#21694)
Fixes https://github.com/denoland/deno/issues/18316
This commit is contained in:
parent
375164c51b
commit
1149ec8848
2 changed files with 26 additions and 0 deletions
|
@ -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>();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue