summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit_node/http_test.ts21
-rw-r--r--ext/node/polyfills/http.ts5
2 files changed, 26 insertions, 0 deletions
diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts
index 5285d8e23..72525d803 100644
--- a/cli/tests/unit_node/http_test.ts
+++ b/cli/tests/unit_node/http_test.ts
@@ -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>();
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts
index d45854162..e49f71702 100644
--- a/ext/node/polyfills/http.ts
+++ b/ext/node/polyfills/http.ts
@@ -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