From df7d8288d984f703722fae161b7d32fae9ab3149 Mon Sep 17 00:00:00 2001 From: Weijia Wang Date: Thu, 12 Dec 2019 15:59:46 +0800 Subject: [PATCH] file_server: get file and fileInfo concurrently (#3486) --- std/http/file_server.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/std/http/file_server.ts b/std/http/file_server.ts index e3caae882b..40a18bd8a5 100755 --- a/std/http/file_server.ts +++ b/std/http/file_server.ts @@ -82,8 +82,7 @@ async function serveFile( req: ServerRequest, filePath: string ): Promise { - 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");