Support HEAD requests part 2

Co-authored-by: Slayer95 <ivojulca@hotmail.com>
This commit is contained in:
Guangcong Luo
2025-07-23 05:09:44 -07:00
committed by GitHub
parent 168fd7a3c9
commit f6fc8cc03b

View File

@@ -162,7 +162,7 @@ export class StaticServer {
// If `alreadySent`, it's been taken care of in `this.stream`.
if (!result.alreadySent && !errorCallback?.(result)) {
res.writeHead(result.status, result.headers);
if (result.status >= 400) {
if (result.status >= 400 || req.method === 'HEAD') {
res.write(`${result.status} ${result.message}`);
}
res.end();