summaryrefslogtreecommitdiff
path: root/cli/bench/http/deno_tcp.ts
diff options
context:
space:
mode:
authorhaturau <135221985+haturatu@users.noreply.github.com>2024-11-20 01:20:47 +0900
committerGitHub <noreply@github.com>2024-11-20 01:20:47 +0900
commit85719a67e59c7aa45bead26e4942d7df8b1b42d4 (patch)
treeface0aecaac53e93ce2f23b53c48859bcf1a36ec /cli/bench/http/deno_tcp.ts
parent67697bc2e4a62a9670699fd18ad0dd8efc5bd955 (diff)
parent186b52731c6bb326c4d32905c5e732d082e83465 (diff)
Merge branch 'denoland:main' into main
Diffstat (limited to 'cli/bench/http/deno_tcp.ts')
-rw-r--r--cli/bench/http/deno_tcp.ts34
1 files changed, 0 insertions, 34 deletions
diff --git a/cli/bench/http/deno_tcp.ts b/cli/bench/http/deno_tcp.ts
deleted file mode 100644
index b79591073..000000000
--- a/cli/bench/http/deno_tcp.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-// Used for benchmarking Deno's networking.
-// TODO(bartlomieju): Replace this with a real HTTP server once
-// https://github.com/denoland/deno/issues/726 is completed.
-// Note: this is a keep-alive server.
-// deno-lint-ignore-file no-console
-const addr = Deno.args[0] || "127.0.0.1:4500";
-const [hostname, port] = addr.split(":");
-const listener = Deno.listen({ hostname, port: Number(port) });
-const response = new TextEncoder().encode(
- "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n",
-);
-async function handle(conn: Deno.Conn): Promise<void> {
- const buffer = new Uint8Array(1024);
- try {
- while (true) {
- await conn.read(buffer);
- await conn.write(response);
- }
- } catch (e) {
- if (
- !(e instanceof Deno.errors.BrokenPipe) &&
- !(e instanceof Deno.errors.ConnectionReset)
- ) {
- throw e;
- }
- }
- conn.close();
-}
-
-console.log("Listening on", addr);
-for await (const conn of listener) {
- handle(conn);
-}