diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-09-06 08:15:00 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-06 08:15:00 +1000 |
commit | 7937ae3f2f5a8c11f52c42676ba56d12fcb59aeb (patch) | |
tree | 1bfb9d994ef638bc26dc9c643e6eca35c2a7ccd9 /tests | |
parent | 6919f33216bb1db2b3596ca6f2f9c2c54f322720 (diff) |
chore(net): soft-remove `Deno.serveHttp()` (#25451)
Towards #22079
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testdata/run/error_for_await.ts | 2 | ||||
-rw-r--r-- | tests/testdata/run/http2_request_url.ts | 1 | ||||
-rw-r--r-- | tests/testdata/run/websocket_server_idletimeout.ts | 1 | ||||
-rw-r--r-- | tests/testdata/run/websocket_server_multi_field_connection_header_test.ts | 1 | ||||
-rw-r--r-- | tests/testdata/workers/http_worker.js | 1 | ||||
-rw-r--r-- | tests/unit/http_test.ts | 121 |
6 files changed, 86 insertions, 41 deletions
diff --git a/tests/testdata/run/error_for_await.ts b/tests/testdata/run/error_for_await.ts index 64c81abe4..ce8571df1 100644 --- a/tests/testdata/run/error_for_await.ts +++ b/tests/testdata/run/error_for_await.ts @@ -5,7 +5,7 @@ for await (const conn of listener) { } function handleConn(conn: Deno.Conn) { - const httpConn = Deno.serveHttp(conn); + const httpConn = (Deno as any).serveHttp(conn); for await (const event of httpConn) { event.respondWith(new Response("html", { status: 200 })); } diff --git a/tests/testdata/run/http2_request_url.ts b/tests/testdata/run/http2_request_url.ts index 5acff8cc2..1c9cab2ea 100644 --- a/tests/testdata/run/http2_request_url.ts +++ b/tests/testdata/run/http2_request_url.ts @@ -5,6 +5,7 @@ const listener = Deno.listen({ console.log("READY"); for await (const conn of listener) { + // @ts-ignore `Deno.serveHttp()` was soft-removed in Deno 2. for await (const { request, respondWith } of Deno.serveHttp(conn)) { const href = new URL(request.url).href; respondWith(new Response(href)); diff --git a/tests/testdata/run/websocket_server_idletimeout.ts b/tests/testdata/run/websocket_server_idletimeout.ts index c33fd9efb..91e359eab 100644 --- a/tests/testdata/run/websocket_server_idletimeout.ts +++ b/tests/testdata/run/websocket_server_idletimeout.ts @@ -5,6 +5,7 @@ const closeDeferred = Promise.withResolvers<void>(); const listener = Deno.listen({ port: 4509 }); console.log("READY"); +// @ts-ignore `Deno.serveHttp()` was soft-removed in Deno 2. const httpConn = Deno.serveHttp(await listener.accept()); const { request, respondWith } = (await httpConn.nextRequest())!; const { response, socket } = Deno.upgradeWebSocket(request, { diff --git a/tests/testdata/run/websocket_server_multi_field_connection_header_test.ts b/tests/testdata/run/websocket_server_multi_field_connection_header_test.ts index d94709767..eee86624d 100644 --- a/tests/testdata/run/websocket_server_multi_field_connection_header_test.ts +++ b/tests/testdata/run/websocket_server_multi_field_connection_header_test.ts @@ -2,6 +2,7 @@ const { promise, resolve } = Promise.withResolvers<void>(); const listener = Deno.listen({ port: 4319 }); console.log("READY"); const conn = await listener.accept(); +// @ts-ignore `Deno.serveHttp()` was soft-removed in Deno 2. const httpConn = Deno.serveHttp(conn); const { request, respondWith } = (await httpConn.nextRequest())!; const { diff --git a/tests/testdata/workers/http_worker.js b/tests/testdata/workers/http_worker.js index c617e2e92..27bc9c038 100644 --- a/tests/testdata/workers/http_worker.js +++ b/tests/testdata/workers/http_worker.js @@ -6,6 +6,7 @@ const listener = Deno.listen({ hostname: "127.0.0.1", port: 4506 }); postMessage("ready"); for await (const conn of listener) { (async () => { + // @ts-ignore `Deno.serveHttp()` was soft-removed in Deno 2. const requests = Deno.serveHttp(conn); for await (const { respondWith } of requests) { respondWith(new Response("Hello world")); diff --git a/tests/unit/http_test.ts b/tests/unit/http_test.ts index 778cc98fd..03b7e9405 100644 --- a/tests/unit/http_test.ts +++ b/tests/unit/http_test.ts @@ -1,4 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// @ts-nocheck `Deno.serveHttp()` was soft-removed in Deno 2. // deno-lint-ignore-file no-deprecated-deno-api @@ -51,7 +52,8 @@ async function writeRequestAndReadResponse(conn: Deno.Conn): Promise<string> { } Deno.test({ permissions: { net: true } }, async function httpServerBasic() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const promise = (async () => { const listener = Deno.listen({ port: listenPort }); const conn = await listener.accept(); @@ -146,7 +148,8 @@ Deno.test( Deno.test( { permissions: { net: true } }, async function httpServerGetRequestBody() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const promise = (async () => { const listener = Deno.listen({ port: listenPort }); const conn = await listener.accept(); @@ -187,7 +190,8 @@ Deno.test( writer.write(new TextEncoder().encode("world")); writer.close(); - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ port: listenPort }); const promise = (async () => { const conn = await listener.accept(); @@ -250,7 +254,8 @@ Deno.test( Deno.test( { permissions: { net: true } }, async function httpServerStreamDuplex() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ port: listenPort }); const promise = (async () => { const conn = await listener.accept(); @@ -363,7 +368,8 @@ Deno.test( Deno.test( { permissions: { net: true } }, async function httpServerRegressionHang() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ port: listenPort }); const promise = (async () => { const conn = await listener.accept(); @@ -482,7 +488,8 @@ Deno.test( Deno.test( { permissions: { net: true } }, async function httpServerEmptyBlobResponse() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ port: listenPort }); const promise = (async () => { const conn = await listener.accept(); @@ -505,7 +512,8 @@ Deno.test( Deno.test( { permissions: { net: true } }, async function httpServerNextRequestResolvesOnClose() { - const httpConnList: Deno.HttpConn[] = []; + // deno-lint-ignore no-explicit-any + const httpConnList: any[] = []; async function serve(l: Deno.Listener) { for await (const conn of l) { @@ -544,7 +552,8 @@ Deno.test( return new Response(s).body!; } - const httpConns: Deno.HttpConn[] = []; + // deno-lint-ignore no-explicit-any + const httpConns: any[] = []; const promise = (async () => { let count = 0; const listener = Deno.listen({ port: listenPort }); @@ -648,7 +657,8 @@ Deno.test( }).pipeThrough(new TextEncoderStream()); } - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ port: listenPort }); const finished = (async () => { const conn = await listener.accept(); @@ -675,7 +685,8 @@ Deno.test( Deno.test( { permissions: { net: true } }, async function httpRequestLatin1Headers() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const promise = (async () => { const listener = Deno.listen({ port: listenPort }); const conn = await listener.accept(); @@ -724,7 +735,8 @@ Deno.test( Deno.test( { permissions: { net: true } }, async function httpServerRequestWithoutPath() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ port: listenPort }); const promise = (async () => { const conn = await listener.accept(); @@ -896,7 +908,8 @@ Deno.test(function httpUpgradeWebSocketWithoutUpgradeHeader() { Deno.test( { permissions: { net: true } }, async function httpCookieConcatenation() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const promise = (async () => { const listener = Deno.listen({ port: listenPort }); const conn = await listener.accept(); @@ -955,7 +968,8 @@ Deno.test( using file = await Deno.open(tmpFile, { write: true, read: true }); await file.write(new Uint8Array(70 * 1024).fill(1)); // 70kb sent in 64kb + 6kb chunks - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ port: listenPort }); const promise = (async () => { const conn = await listener.accept(); @@ -1094,7 +1108,8 @@ Deno.test( { permissions: { net: true } }, async function httpServerDoesntLeakResources2() { let listener: Deno.Listener; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const promise = (async () => { listener = Deno.listen({ port: listenPort }); @@ -1161,7 +1176,8 @@ Deno.test( const hostname = "localhost"; const port = listenPort; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ hostname, port }); async function server() { const tcpConn = await listener.accept(); @@ -1248,7 +1264,8 @@ Deno.test( const hostname = "localhost"; const port = listenPort; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ hostname, port }); async function server() { const tcpConn = await listener.accept(); @@ -1279,7 +1296,8 @@ Deno.test( Deno.test( { permissions: { net: true } }, async function httpServerRespondNonAsciiUint8Array() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ port: listenPort }); const promise = (async () => { const conn = await listener.accept(); @@ -1318,7 +1336,8 @@ Deno.test( async function httpServerOnUnixSocket() { const filePath = tmpUnixSocketPath(); - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const promise = (async () => { const listener = Deno.listen({ path: filePath, transport: "unix" }); const conn = await listener.accept(); @@ -1367,7 +1386,8 @@ Deno.test({ const data = { hello: "deno", now: "with", compressed: "body" }; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const tcpConn = await listener.accept(); httpConn = Deno.serveHttp(tcpConn); @@ -1419,7 +1439,8 @@ Deno.test({ const data = { hello: "deno", now: "with", compressed: "body" }; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const tcpConn = await listener.accept(); httpConn = Deno.serveHttp(tcpConn); @@ -1473,7 +1494,8 @@ Deno.test({ const hostname = "localhost"; const port = listenPort; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -1526,7 +1548,8 @@ Deno.test({ const hostname = "localhost"; const port = listenPort; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -1582,7 +1605,8 @@ Deno.test({ const hostname = "localhost"; const port = listenPort; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -1635,7 +1659,8 @@ Deno.test({ const hostname = "localhost"; const port = listenPort; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -1695,7 +1720,8 @@ Deno.test({ const hostname = "localhost"; const port = listenPort; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -1754,7 +1780,8 @@ Deno.test({ const hostname = "localhost"; const port = listenPort; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -1810,7 +1837,8 @@ Deno.test({ const hostname = "localhost"; const port = listenPort; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -1871,7 +1899,8 @@ Deno.test({ const data = { hello: "deno", now: "with", compressed: "body" }; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const tcpConn = await listener.accept(); httpConn = Deno.serveHttp(tcpConn); @@ -1933,7 +1962,8 @@ Deno.test({ const data = { hello: "deno", now: "with", compressed: "body" }; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const tcpConn = await listener.accept(); httpConn = Deno.serveHttp(tcpConn); @@ -1995,7 +2025,8 @@ Deno.test({ const port = listenPort; let contentLength: string; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -2061,7 +2092,8 @@ Deno.test({ const port = listenPort; let contentLength: string; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -2122,7 +2154,8 @@ Deno.test({ const port = listenPort; let contentLength: string; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const listener = Deno.listen({ hostname, port }); const tcpConn = await listener.accept(); @@ -2182,7 +2215,8 @@ Deno.test( const body = "aa\n" + "deno.land large body\n".repeat(TLS_PACKET_SIZE) + "zz"; - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const promise = (async () => { const listener = Deno.listen({ port: listenPort }); const conn = await listener.accept(); @@ -2229,7 +2263,8 @@ Deno.test( } writer.close(); - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const promise = (async () => { const listener = Deno.listen({ port: listenPort }); const conn = await listener.accept(); @@ -2339,7 +2374,8 @@ Deno.test( { permissions: { net: true } }, async function httpServerRequestResponseClone() { const body = "deno".repeat(64 * 1024); - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const listener = Deno.listen({ port: listenPort }); const promise = (async () => { const conn = await listener.accept(); @@ -2403,7 +2439,8 @@ Deno.test({ const listener = Deno.listen({ hostname, port }); const listener2 = Deno.listen({ hostname, port: port2 }); - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function server() { const tcpConn = await listener.accept(); httpConn = Deno.serveHttp(tcpConn); @@ -2420,7 +2457,8 @@ Deno.test({ const writer = ts.writable.getWriter(); writer.write(encoder.encode("hello")); - let httpConn2: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn2: any; async function server2() { const tcpConn = await listener2.accept(); httpConn2 = Deno.serveHttp(tcpConn); @@ -2499,7 +2537,8 @@ Deno.test("case insensitive comma value finder", async (t) => { async function httpServerWithErrorBody( listener: Deno.Listener, compression: boolean, -): Promise<Deno.HttpConn> { + // deno-lint-ignore no-explicit-any +): Promise<any> { const conn = await listener.accept(); listener.close(); const httpConn = Deno.serveHttp(conn); @@ -2627,7 +2666,8 @@ Deno.test({ name: "request signal is aborted when response errors", permissions: { net: true }, async fn() { - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; const promise = (async () => { const listener = Deno.listen({ port: listenPort }); const conn = await listener.accept(); @@ -2682,7 +2722,8 @@ Deno.test("proxy with fetch", async () => { return new Response("Hello world"); }); - let httpConn: Deno.HttpConn; + // deno-lint-ignore no-explicit-any + let httpConn: any; async function handleHttp(conn: Deno.Conn) { httpConn = Deno.serveHttp(conn); for await (const e of httpConn) { |