minimalistic-server 0.0.24 → 0.0.25
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 +10 -6
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1247,6 +1247,7 @@ export class FileResponse extends Response {
|
|
|
1247
1247
|
#dataPromise = null;
|
|
1248
1248
|
|
|
1249
1249
|
#maxChunkSize = 4 * 1024 * 1024;
|
|
1250
|
+
#defaultfragmentSize = 256 * 1024;
|
|
1250
1251
|
#fragmentRequestMap = new WeakMap();
|
|
1251
1252
|
#makeNotFoundResponse = null;
|
|
1252
1253
|
#urlPathForDirectory = null;
|
|
@@ -1279,10 +1280,17 @@ export class FileResponse extends Response {
|
|
|
1279
1280
|
...data.headers,
|
|
1280
1281
|
'Content-Range': `bytes ${requestedFragment.offset}-${requestedFragment.offset + requestedFragment.size - 1}/${data.size}`,
|
|
1281
1282
|
'Content-Length': `${requestedFragment.size}`,
|
|
1282
|
-
|
|
1283
|
+
'Cache-Control': 'no-store, no-cache, must-revalidate',
|
|
1283
1284
|
};
|
|
1284
1285
|
}
|
|
1285
1286
|
|
|
1287
|
+
if (typeof data.body === 'function') {
|
|
1288
|
+
return {
|
|
1289
|
+
...data.headers,
|
|
1290
|
+
'Cache-Control': 'no-store, no-cache, must-revalidate',
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1286
1294
|
return data.headers;
|
|
1287
1295
|
}
|
|
1288
1296
|
|
|
@@ -1356,7 +1364,7 @@ export class FileResponse extends Response {
|
|
|
1356
1364
|
offset = data.size - 1;
|
|
1357
1365
|
}
|
|
1358
1366
|
|
|
1359
|
-
let size = (numbers[1] ?? (this.#
|
|
1367
|
+
let size = (numbers[1] ?? (this.#defaultfragmentSize - 1 + offset)) - offset + 1;
|
|
1360
1368
|
|
|
1361
1369
|
if (size < 0) {
|
|
1362
1370
|
size = 0;
|
|
@@ -1452,10 +1460,6 @@ ${urlPath ? `<a href="/${parentUrlPath}">Up</a><hr>` : ''}
|
|
|
1452
1460
|
const readAsDirectory = stat.isDirectory() && this.#urlPathForDirectory !== null;
|
|
1453
1461
|
const body = size > this.#maxChunkSize ? (fragmentRequest => this.#getBodyStream(fragmentRequest)) : (readAsDirectory ? (() => this.#getDirectoryStream()) : await filehandle.readFile());
|
|
1454
1462
|
|
|
1455
|
-
if (readAsDirectory) {
|
|
1456
|
-
this.addCustomHeaders({ 'Cache-Control': 'no-store, no-cache, must-revalidate' });
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
1463
|
resolve({
|
|
1460
1464
|
code: this.#code,
|
|
1461
1465
|
headers: this.getMergedWithOtherHeaders({
|