From 2f9cdaa67d5a24e147c74808cba2b610f0f50381 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Thu, 26 Sep 2024 12:53:39 +0900 Subject: [PATCH] fixes --- ext/node/polyfills/http.ts | 17 ++++++++++++----- tests/unit_node/http_test.ts | 6 ++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 3ba2164714..968611025d 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -419,6 +419,14 @@ class ClientRequest extends OutgoingMessage { _writeHeader() { const url = this._createUrlStrFromOptions(); + const headers = []; + for (const key in this[kOutHeaders]) { + if (Object.hasOwn(this[kOutHeaders], key)) { + const entry = this[kOutHeaders][key]; + this._processHeader(headers, entry[0], entry[1], false); + } + } + if ( this.method === "POST" || this.method === "PATCH" || this.method === "PUT" ) { @@ -447,6 +455,10 @@ class ClientRequest extends OutgoingMessage { await op_node_http_wait_for_connection(connRid); this.emit("requestReady"); const res = await op_node_http_await_response(rid); + if (this._timeout) { + this._timeout.removeEventListener("abort", this._timeoutCb); + webClearTimeout(this._timeout[timerId]); + } const incoming = new IncomingMessageForClient(this.socket); incoming.req = this; this.res = incoming; @@ -659,11 +671,6 @@ class ClientRequest extends OutgoingMessage { } this.destroyed = true; - const rid = this._client?.[internalRidSymbol]; - if (rid) { - core.tryClose(rid); - } - // Request might be closed before we actually made it if (this._req !== undefined && this._req.cancelHandleRid !== null) { core.tryClose(this._req.cancelHandleRid); diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts index f3103c4281..0abd94300b 100644 --- a/tests/unit_node/http_test.ts +++ b/tests/unit_node/http_test.ts @@ -524,7 +524,8 @@ Deno.test("[node/http] send request with chunked body", async () => { }; const abortController = new AbortController(); const servePromise = Deno.serve({ - hostname, + // TODO(kt3k): Enable this line for better compatibility with Node.js + // hostname, port, signal: abortController.signal, onListen: undefined, @@ -571,7 +572,8 @@ Deno.test("[node/http] send request with chunked body as default", async () => { }; const abortController = new AbortController(); const servePromise = Deno.serve({ - hostname, + // TODO(kt3k): Enable this line for better compatibility with Node.js + // hostname, port, signal: abortController.signal, onListen: undefined,