minimalistic-server 0.0.36 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +12 -5
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -44,6 +44,8 @@ const mimeTypes = {
|
|
|
44
44
|
"ahead": "application/vnd.ahead.space",
|
|
45
45
|
"ai": "application/postscript",
|
|
46
46
|
"aif": "audio/x-aiff",
|
|
47
|
+
"aifc": "audio/x-aiff",
|
|
48
|
+
"aiff": "audio/x-aiff",
|
|
47
49
|
"air": "application/vnd.adobe.air-application-installer-package+zip",
|
|
48
50
|
"ait": "application/vnd.dvb.ait",
|
|
49
51
|
"ami": "application/vnd.amiga.ami",
|
|
@@ -312,6 +314,7 @@ const mimeTypes = {
|
|
|
312
314
|
"m21": "application/mp21",
|
|
313
315
|
"m3u": "audio/x-mpegurl",
|
|
314
316
|
"m3u8": "application/vnd.apple.mpegurl",
|
|
317
|
+
"m4a": "audio/mp4",
|
|
315
318
|
"m4v": "video/x-m4v",
|
|
316
319
|
"ma": "application/mathematica",
|
|
317
320
|
"mads": "application/mads+xml",
|
|
@@ -484,7 +487,8 @@ const mimeTypes = {
|
|
|
484
487
|
"qps": "application/vnd.publishare-delta-tree",
|
|
485
488
|
"qt": "video/quicktime",
|
|
486
489
|
"qxd": "application/vnd.quark.quarkxpress",
|
|
487
|
-
"
|
|
490
|
+
"ra": "audio/vnd.rn-realaudio",
|
|
491
|
+
"ram": "audio/vnd.rn-realaudio",
|
|
488
492
|
"rar": "application/x-rar-compressed",
|
|
489
493
|
"ras": "image/x-cmu-raster",
|
|
490
494
|
"rcprofile": "application/vnd.ipunplugged.rcprofile",
|
|
@@ -499,6 +503,7 @@ const mimeTypes = {
|
|
|
499
503
|
"rlc": "image/vnd.fujixerox.edmics-rlc",
|
|
500
504
|
"rld": "application/resource-lists-diff+xml",
|
|
501
505
|
"rm": "application/vnd.rn-realmedia",
|
|
506
|
+
"rmi": "audio/mid",
|
|
502
507
|
"rmp": "audio/x-pn-realaudio-plugin",
|
|
503
508
|
"rms": "application/vnd.jcp.javame.midlet-rms",
|
|
504
509
|
"rnc": "application/relax-ng-compact-syntax",
|
|
@@ -551,6 +556,7 @@ const mimeTypes = {
|
|
|
551
556
|
"sm": "application/vnd.stepmania.stepchart",
|
|
552
557
|
"smf": "application/vnd.stardivision.math",
|
|
553
558
|
"smi": "application/smil+xml",
|
|
559
|
+
"snd": "audio/basic",
|
|
554
560
|
"snf": "application/x-font-snf",
|
|
555
561
|
"spf": "application/vnd.yamaha.smaf-phrase",
|
|
556
562
|
"spl": "application/x-futuresplash",
|
|
@@ -1585,7 +1591,7 @@ export class FileResponse extends Response {
|
|
|
1585
1591
|
#dataPromise = null;
|
|
1586
1592
|
|
|
1587
1593
|
#maxChunkSize = 4 * 1024 * 1024;
|
|
1588
|
-
#
|
|
1594
|
+
#maxFragmentSize = 16 * 1024 * 1024 * 1024;
|
|
1589
1595
|
#fragmentRequestMap = new WeakMap();
|
|
1590
1596
|
#makeNotFoundResponse = null;
|
|
1591
1597
|
#urlPathForDirectory = null;
|
|
@@ -1714,7 +1720,7 @@ export class FileResponse extends Response {
|
|
|
1714
1720
|
offset = data.size - 1;
|
|
1715
1721
|
}
|
|
1716
1722
|
|
|
1717
|
-
let size = (numbers[1] ?? (this.#
|
|
1723
|
+
let size = (numbers[1] ?? (this.#maxFragmentSize - 1 + offset)) - offset + 1;
|
|
1718
1724
|
|
|
1719
1725
|
if (size < 0) {
|
|
1720
1726
|
size = 0;
|
|
@@ -1789,11 +1795,12 @@ ${urlPath ? `<a href="/${parentUrlPath}">Up</a><hr>` : ''}
|
|
|
1789
1795
|
try {
|
|
1790
1796
|
const requestedPosition = fragmentRequest?.offset ?? 0;
|
|
1791
1797
|
const requestedSize = fragmentRequest?.size ?? data.size;
|
|
1798
|
+
const maxChunkSize = fragmentRequest ? 256 * 1024 : this.#maxChunkSize;
|
|
1792
1799
|
|
|
1793
1800
|
filehandle = await currentFsPromiseModule.open(this.#filePath, 'r');
|
|
1794
1801
|
|
|
1795
|
-
for (let offset = 0; offset < requestedSize && !this.#blocked; offset +=
|
|
1796
|
-
const size = Math.min(
|
|
1802
|
+
for (let offset = 0; offset < requestedSize && !this.#blocked; offset += maxChunkSize) {
|
|
1803
|
+
const size = Math.min(maxChunkSize, requestedSize - offset);
|
|
1797
1804
|
const chunk = await filehandle.read(Buffer.alloc(size), 0, size, offset + requestedPosition);
|
|
1798
1805
|
yield chunk.buffer;
|
|
1799
1806
|
}
|