From a19a196477dd5e6102be9a8b9f125a300d34d17e Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 19 Sep 2023 15:45:50 +0200 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaël Zasso Co-authored-by: Tobias Nießen --- doc/api/http.md | 6 ++++-- lib/internal/http/static.js | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index d33b975d919702..1ef0ba6f9517da 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -3589,6 +3589,8 @@ added: REPLACEME files are filtered. **Default:** filters all dot files. * `log` {Function|null} called when sending a response to the client. **Default:** `console.log`. + * `statusCode` {integer} The status code that is sent to the client. + * `url` {string} the (origin-relative) URL that was requested. * `onStart` {Function} called the server starts listening to requests. **Default:** logs the URL to the console. @@ -3600,10 +3602,10 @@ When specifying a `host` other than `localhost`, you are exposing your local file system to all the machines that can connect to your computer. If specified and not `null`, `filter` will be called with two arguments: the -first one if the request URL string (the URL that is present in the actual HTTP +first one is the request URL string (the URL that is present in the actual HTTP request), and the second one is the `file:` `URL` that was generated from the base directory and the request URL. If the function returns a falsy value, the -request will be blocked. +server will respond with a 403 HTTP error. If `port` is omitted or is 0, the operating system will assign an arbitrary unused port, which it's output will be the standard output. diff --git a/lib/internal/http/static.js b/lib/internal/http/static.js index 9180635aff9dee..c21f1d76ff24ce 100644 --- a/lib/internal/http/static.js +++ b/lib/internal/http/static.js @@ -71,6 +71,7 @@ function createStaticServer(options = kEmptyObject) { '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.png': 'image/png', + '.wasm': 'application/wasm', '.webp': 'image/webp', '.woff2': 'font/woff2', ...mimeOverrides,