0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00

file_server: get file and fileInfo concurrently (#3486)

This commit is contained in:
Weijia Wang 2019-12-12 15:59:46 +08:00 committed by Ry Dahl
parent 7f27f649cc
commit df7d8288d9

View file

@ -82,8 +82,7 @@ async function serveFile(
req: ServerRequest,
filePath: string
): Promise<Response> {
const file = await open(filePath);
const fileInfo = await stat(filePath);
const [file, fileInfo] = await Promise.all([open(filePath), stat(filePath)]);
const headers = new Headers();
headers.set("content-length", fileInfo.len.toString());
headers.set("content-type", "text/plain");