@autonomys/file-server 1.6.4-beta.0 → 1.6.4
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/http/headers.d.ts.map +1 -1
- package/dist/http/headers.js +10 -20
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../src/http/headers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAkF3E,MAAM,MAAM,oBAAoB,GAAG;IACjC,oBAAoB,EAAE,OAAO,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,6BAA6B,GACxC,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,UAAU,gBAAgB,EAC1B,wBAA4C,eAAe,KAC1D,
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../src/http/headers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAkF3E,MAAM,MAAM,oBAAoB,GAAG;IACjC,oBAAoB,EAAE,OAAO,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,6BAA6B,GACxC,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,UAAU,gBAAgB,EAC1B,wBAA4C,eAAe,KAC1D,oBAyDF,CAAA;AAED,eAAO,MAAM,+BAA+B,GAC1C,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,UAAU,gBAAgB,SAS3B,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,KAAK,OAAO,KAAG,SAAS,GAAG,SAgBvD,CAAA"}
|
package/dist/http/headers.js
CHANGED
|
@@ -82,32 +82,22 @@ export const handleDownloadResponseHeaders = (req, res, metadata, { byteRange =
|
|
|
82
82
|
: isDocumentNavigation(req);
|
|
83
83
|
const mimeType = contentType.toLowerCase();
|
|
84
84
|
const isMediaType = mimeType.startsWith('video/') || mimeType.startsWith('audio/');
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const canAdvertiseRanges = metadata.size != null;
|
|
90
|
-
if (canAdvertiseRanges) {
|
|
91
|
-
res.set('Accept-Ranges', 'bytes');
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
res.set('Accept-Ranges', 'none');
|
|
95
|
-
}
|
|
96
|
-
if (compressedButNotEncrypted &&
|
|
97
|
-
shouldHandleEncoding &&
|
|
98
|
-
!rawMode &&
|
|
99
|
-
!byteRange &&
|
|
100
|
-
!isMediaType) {
|
|
85
|
+
// Determine compression handling: either browser decompresses via Content-Encoding,
|
|
86
|
+
// or we decompress server-side
|
|
87
|
+
const canUseBrowserDecompression = compressedButNotEncrypted && shouldHandleEncoding && !rawMode && !byteRange && !isMediaType;
|
|
88
|
+
if (canUseBrowserDecompression) {
|
|
101
89
|
res.set('Content-Encoding', 'deflate');
|
|
102
90
|
}
|
|
103
|
-
else if (
|
|
91
|
+
else if (compressedButNotEncrypted) {
|
|
104
92
|
shouldDecompressBody = true;
|
|
105
93
|
}
|
|
106
|
-
|
|
94
|
+
// Set Accept-Ranges once based on final decompression decision
|
|
95
|
+
// Can't advertise ranges when decompressing (can't seek in stream) or when size unknown
|
|
96
|
+
const canAdvertiseRanges = !shouldDecompressBody && metadata.size != null;
|
|
97
|
+
res.set('Accept-Ranges', canAdvertiseRanges ? 'bytes' : 'none');
|
|
98
|
+
if (shouldDecompressBody) {
|
|
107
99
|
// When decompressing, we can't know the output size upfront
|
|
108
100
|
// Don't set Content-Length - this will use chunked transfer encoding
|
|
109
|
-
// Also don't advertise ranges since we can't seek in decompressed stream
|
|
110
|
-
res.set('Accept-Ranges', 'none');
|
|
111
101
|
}
|
|
112
102
|
else if (byteRange && metadata.size != null) {
|
|
113
103
|
// For range requests on non-compressed content
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/file-server",
|
|
3
3
|
"packageManager": "yarn@4.7.0",
|
|
4
|
-
"version": "1.6.4
|
|
4
|
+
"version": "1.6.4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"typescript": "^5.8.3"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@autonomys/asynchronous": "^1.6.4
|
|
52
|
-
"@autonomys/auto-dag-data": "^1.6.4
|
|
53
|
-
"@autonomys/auto-utils": "^1.6.4
|
|
51
|
+
"@autonomys/asynchronous": "^1.6.4",
|
|
52
|
+
"@autonomys/auto-dag-data": "^1.6.4",
|
|
53
|
+
"@autonomys/auto-utils": "^1.6.4",
|
|
54
54
|
"@keyvhq/sqlite": "^2.1.7",
|
|
55
55
|
"cache-manager": "^6.4.2",
|
|
56
56
|
"express": "^4.19.2",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"uuid": "^11.1.0",
|
|
63
63
|
"zod": "^3.24.2"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "b1f231792632e72725552b4df97f4afbc7ffabdd"
|
|
66
66
|
}
|