MCPcopy
hub / github.com/http-party/http-server / tryServeWithBrotli

Function tryServeWithBrotli

lib/core/index.js:454–469  ·  view source on GitHub ↗
(shouldTryGzip)

Source from the content-addressed store, hash-verified

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);

Callers 1

index.jsFile · 0.85

Calls 3

serveFunction · 0.85
tryServeWithGzipFunction · 0.85
statFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…