summaryrefslogtreecommitdiff
path: root/std/http/file_server.ts
diff options
context:
space:
mode:
authorWeijia Wang <starkwang@126.com>2019-12-12 15:59:46 +0800
committerRy Dahl <ry@tinyclouds.org>2019-12-12 15:59:46 +0800
commitdf7d8288d984f703722fae161b7d32fae9ab3149 (patch)
tree827e421c9f94c1b13abe918c20924603a27553a7 /std/http/file_server.ts
parent7f27f649cca0e928a422aaa6182988087338e435 (diff)
file_server: get file and fileInfo concurrently (#3486)
Diffstat (limited to 'std/http/file_server.ts')
-rwxr-xr-xstd/http/file_server.ts3
1 files changed, 1 insertions, 2 deletions
diff --git a/std/http/file_server.ts b/std/http/file_server.ts
index e3caae882..40a18bd8a 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<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");