From 867a6d303285cdffd060e6bb4b0e97de73925cfe Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Wed, 17 May 2023 01:20:32 +0200 Subject: refactor(node): reimplement http client (#19122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit reimplements most of "node:http" client APIs using "ext/fetch". There is some duplicated code and two removed Node compat tests that will be fixed in follow up PRs. --------- Co-authored-by: Bartek IwaƄczuk --- cli/tests/unit_node/http_test.ts | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'cli/tests/unit_node') diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts index 556ba1684..08d2626d7 100644 --- a/cli/tests/unit_node/http_test.ts +++ b/cli/tests/unit_node/http_test.ts @@ -185,6 +185,7 @@ Deno.test("[node/http] server can respond with 101, 204, 205, 304 status", async Deno.test("[node/http] request default protocol", async () => { const promise = deferred(); + const promise2 = deferred(); const server = http.createServer((_, res) => { res.end("ok"); }); @@ -198,6 +199,7 @@ Deno.test("[node/http] request default protocol", async () => { server.close(); }); assertEquals(res.statusCode, 200); + promise2.resolve(); }, ); req.end(); @@ -206,6 +208,7 @@ Deno.test("[node/http] request default protocol", async () => { promise.resolve(); }); await promise; + await promise2; }); Deno.test("[node/http] request with headers", async () => { @@ -292,32 +295,6 @@ Deno.test("[node/http] http.IncomingMessage can be created without url", () => { }); */ -Deno.test("[node/http] set http.IncomingMessage.statusMessage", () => { - // deno-lint-ignore no-explicit-any - const message = new (http as any).IncomingMessageForClient( - new Response(null, { status: 404, statusText: "Not Found" }), - { - encrypted: true, - readable: false, - remoteAddress: "foo", - address() { - return { port: 443, family: "IPv4" }; - }, - // deno-lint-ignore no-explicit-any - end(_cb: any) { - return this; - }, - // deno-lint-ignore no-explicit-any - destroy(_e: any) { - return; - }, - }, - ); - assertEquals(message.statusMessage, "Not Found"); - message.statusMessage = "boom"; - assertEquals(message.statusMessage, "boom"); -}); - Deno.test("[node/http] send request with non-chunked body", async () => { let requestHeaders: Headers; let requestBody = ""; -- cgit v1.2.3