mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
file_server: get file and fileInfo concurrently (#3486)
This commit is contained in:
parent
7f27f649cc
commit
df7d8288d9
1 changed files with 1 additions and 2 deletions
|
@ -82,8 +82,7 @@ async function serveFile(
|
||||||
req: ServerRequest,
|
req: ServerRequest,
|
||||||
filePath: string
|
filePath: string
|
||||||
): Promise<Response> {
|
): Promise<Response> {
|
||||||
const file = await open(filePath);
|
const [file, fileInfo] = await Promise.all([open(filePath), stat(filePath)]);
|
||||||
const fileInfo = await stat(filePath);
|
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
headers.set("content-length", fileInfo.len.toString());
|
headers.set("content-length", fileInfo.len.toString());
|
||||||
headers.set("content-type", "text/plain");
|
headers.set("content-type", "text/plain");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue