-
Notifications
You must be signed in to change notification settings - Fork 668
Description
The file server seems to have some points where the implementation could be refactored.
-
HEAD request support
Golang's std server and hyper-staticfile seem to support this.
I think it's easy to implement just by conditionally branching withreq.method === "HEAD". -
In recent versions of Deno, the Date header is automatically set if it's not present. So I think adding the Date header inside
setBaseHeader()is unnecessary.
(chore(http/file_server): remove unnecessary Date header generation #3364)
https://github.com/denoland/deno_std/blob/699ba98572f28e6dfb423abe959502ba6a96c551/http/file_server.ts#L328-L334 -
Inside
serveDirIndexthere are serial await calls. It seems that it can be speeded up by calling this in parallel.
(perf(http/file_server): read fileinfo in parallel #3363)for await (const entry of Deno.readDir(dirPath)) { ... const fileInfo = await Deno.stat(filePath); ... } // https://github.com/denoland/deno_std/blob/699ba98572f28e6dfb423abe959502ba6a96c551/http/file_server.ts#L282
-
Currently it returns content with 200 OK for paths like
/path//////to////file.txt. I think such requests should be redirected to a normalized path. (fix(http/file_server): Redirect non-canonical URL to canonical URL #3362) -
It would be nice to use JSDoc's
@moduletag to enhance the documentation. (chore(http/file_server): add module documentation #3368)
I will submit a PR on these points later.