@eslym/sveltekit-adapter-bun 2.1.2 → 2.1.3
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/dist/files/index.js +33 -35
- package/package.json +1 -1
package/dist/files/index.js
CHANGED
|
@@ -217,44 +217,42 @@ async function serve_static({ request }) {
|
|
|
217
217
|
const headers = new Headers(data.headers.map((h2, i) => [headersMap[i], h2]));
|
|
218
218
|
const file = data.file;
|
|
219
219
|
headers.set("content-type", file.type);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
status: 416,
|
|
247
|
-
headers
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
headers.set("content-range", `bytes ${startBytes}-${endBytes - 1}/${size}`);
|
|
251
|
-
headers.set("content-length", `${endBytes - startBytes}`);
|
|
252
|
-
headers.set("accept-range", "bytes");
|
|
253
|
-
return new Response(file.slice(startBytes, endBytes), {
|
|
254
|
-
status: 206,
|
|
220
|
+
const range = parse_range(request.headers);
|
|
221
|
+
if (range) {
|
|
222
|
+
const size = data.headers[2];
|
|
223
|
+
if (!range[0]) {
|
|
224
|
+
headers.set("content-range", `bytes */${size}`);
|
|
225
|
+
headers.set("content-length", "0");
|
|
226
|
+
return new Response(null, {
|
|
227
|
+
status: 416,
|
|
228
|
+
headers
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const [_2, rangeStart, rangeEnd] = range;
|
|
232
|
+
let startBytes = 0;
|
|
233
|
+
let endBytes = size;
|
|
234
|
+
if (rangeStart < 0) {
|
|
235
|
+
startBytes = size + rangeStart;
|
|
236
|
+
} else {
|
|
237
|
+
startBytes = rangeStart;
|
|
238
|
+
if (rangeEnd)
|
|
239
|
+
endBytes = rangeEnd + 1;
|
|
240
|
+
}
|
|
241
|
+
if (endBytes <= startBytes || startBytes < 0 || endBytes > size) {
|
|
242
|
+
headers.set("content-range", `bytes */${size}`);
|
|
243
|
+
headers.set("content-length", "0");
|
|
244
|
+
return new Response(null, {
|
|
245
|
+
status: 416,
|
|
255
246
|
headers
|
|
256
247
|
});
|
|
257
248
|
}
|
|
249
|
+
headers.set("content-range", `bytes ${startBytes}-${endBytes - 1}/${size}`);
|
|
250
|
+
headers.set("content-length", `${endBytes - startBytes}`);
|
|
251
|
+
headers.set("accept-range", "bytes");
|
|
252
|
+
return new Response(file.slice(startBytes, endBytes), {
|
|
253
|
+
status: 206,
|
|
254
|
+
headers
|
|
255
|
+
});
|
|
258
256
|
}
|
|
259
257
|
headers.set("cache-control", data.immutable ? immutable_ttl : asset_ttl);
|
|
260
258
|
if (request.headers.has("if-none-match") && request.headers.get("if-none-match") === data.headers[1]) {
|
package/package.json
CHANGED