1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-14 11:27:57 -05:00
denoland-deno/cli/bench/http/deno_http_flash_post_bin.js
Marcos Casagrande 569287b15b
perf(ext/fetch): consume body using ops (#16038)
This commit adds a fast path to `Request` and `Response` that
make consuming request bodies much faster when using `Body#text`,
`Body#arrayBuffer`, and `Body#blob`, if the body is a FastStream.
Because the response bodies for `fetch` are FastStream, this speeds up
consuming `fetch` response bodies significantly.
2022-10-04 15:48:50 +02:00

16 lines
403 B
JavaScript

// 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 { serve } = Deno;
async function handler(request) {
try {
const buffer = await request.arrayBuffer();
return new Response(buffer.byteLength);
} catch (e) {
console.log(e);
}
}
serve(handler, { hostname, port });