diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2022-07-01 12:59:01 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-01 12:59:01 +0530 |
commit | 350994e6a66ed78b0fa38c1ffad4928297ffd9b3 (patch) | |
tree | bf00b1c2323d5fb85b07b2a16d861e76561eedc3 /cli/bench/http/deno_http_read_headers.js | |
parent | a27acbc2ec63dd684cf57990b30d757cd0477d9b (diff) |
chore(cli/bench): Add more HTTP benchmarks (#14995)
Diffstat (limited to 'cli/bench/http/deno_http_read_headers.js')
-rw-r--r-- | cli/bench/http/deno_http_read_headers.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cli/bench/http/deno_http_read_headers.js b/cli/bench/http/deno_http_read_headers.js new file mode 100644 index 000000000..75346b38d --- /dev/null +++ b/cli/bench/http/deno_http_read_headers.js @@ -0,0 +1,17 @@ +// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. + +const addr = Deno.args[0] || "127.0.0.1:4500"; +const [hostname, port] = addr.split(":"); +const listener = Deno.listen({ hostname, port: Number(port) }); +console.log("Server listening on", addr); + +for await (const conn of listener) { + (async () => { + const requests = Deno.serveHttp(conn); + for await (const { respondWith, request } of requests) { + const bar = request.headers.get("foo"); + respondWith(new Response(bar)) + .catch((e) => console.log(e)); + } + })(); +} |