(shouldTryGzip)
| 452 | |
| 453 | // serve brotli file if exists, otherwise try gzip |
| 454 | function tryServeWithBrotli(shouldTryGzip) { |
| 455 | try { |
| 456 | fs.stat(brotliFile, (err, stat) => { |
| 457 | if (!err && stat.isFile()) { |
| 458 | file = brotliFile; |
| 459 | serve(stat); |
| 460 | } else if (shouldTryGzip) { |
| 461 | tryServeWithGzip(); |
| 462 | } else { |
| 463 | statFile(); |
| 464 | } |
| 465 | }); |
| 466 | } catch (err) { |
| 467 | status[500](res, next, { error: err.message }); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | const shouldTryBrotli = opts.brotli && shouldCompressBrotli(req); |
| 472 | const shouldTryGzip = opts.gzip && shouldCompressGzip(req); |
no test coverage detected
searching dependent graphs…