(res, filePath)
| 365 | } |
| 366 | |
| 367 | async function serveFile(res, filePath) { |
| 368 | try { |
| 369 | const stat = await fsp.stat(filePath); |
| 370 | res.writeHead(200, { |
| 371 | "Content-Type": getMime(filePath), |
| 372 | "Content-Length": stat.size, |
| 373 | "Accept-Ranges": "bytes" |
| 374 | }); |
| 375 | fs.createReadStream(filePath).pipe(res); |
| 376 | } catch { |
| 377 | text(res, 404, "Not found"); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | function readBody(req) { |
| 382 | return new Promise((resolve, reject) => { |
no test coverage detected