diff --git a/std/examples/chat/server.ts b/std/examples/chat/server.ts index d28f9f43fc324e..e6b8cd9b005cee 100644 --- a/std/examples/chat/server.ts +++ b/std/examples/chat/server.ts @@ -1,4 +1,5 @@ import { listenAndServe } from "../../http/server.ts"; +import * as path from "../../path/mod.ts"; import { acceptWebSocket, acceptable, @@ -48,7 +49,7 @@ listenAndServe(addr, async req => { }); } else { // server launched by deno run ./server.ts - const file = await Deno.open(u.pathname); + const file = await Deno.open(path.resolve(u.href)); req.respond({ status: 200, headers: new Headers({ diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts index e09771e5208c6a..dd03658f55f7e2 100644 --- a/std/examples/chat/server_test.ts +++ b/std/examples/chat/server_test.ts @@ -8,7 +8,7 @@ import { delay } from "../../util/async.ts"; const port = randomPort(); -const { test, build } = Deno; +const { test } = Deno; async function startServer(): Promise { const server = Deno.run({ @@ -16,7 +16,7 @@ async function startServer(): Promise { Deno.execPath(), "--allow-net", "--allow-read", - "server.ts", + "./server.ts", `127.0.0.1:${port}` ], cwd: "examples/chat", @@ -35,11 +35,7 @@ async function startServer(): Promise { return server; } -// TODO: https://github.com/denoland/deno/issues/4108 -const ignore = build.os == "win"; - test({ - ignore, name: "GET / should serve html", async fn() { const server = await startServer(); @@ -58,7 +54,6 @@ test({ }); test({ - ignore, name: "GET /ws should upgrade conn to ws", async fn() { const server = await startServer(); diff --git a/std/http/server_test.ts b/std/http/server_test.ts index d9ce3ba970849a..9572604566dc77 100644 --- a/std/http/server_test.ts +++ b/std/http/server_test.ts @@ -473,10 +473,10 @@ test({ await req.respond({ body: new TextEncoder().encode(req.url) }); } } - - const server = serve(":8123"); + const port = randomPort(); + const server = serve({ port }); const p = iteratorReq(server); - const conn = await Deno.connect({ hostname: "127.0.0.1", port: 8123 }); + const conn = await Deno.connect({ hostname: "127.0.0.1", port }); await Deno.writeAll( conn, new TextEncoder().encode("GET /hello HTTP/1.1\r\n\r\n")