@pnpm/fetching.tarball-fetcher 1101.0.2 → 1101.0.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/lib/remoteTarballFetcher.js +20 -1
- package/package.json +11 -11
|
@@ -69,6 +69,10 @@ export function createDownloader(fetchFromRegistry, gotOpts) {
|
|
|
69
69
|
try {
|
|
70
70
|
const res = await fetchFromRegistry(url, {
|
|
71
71
|
authHeaderValue,
|
|
72
|
+
// Tarballs are already compressed; ask the server not to apply an additional
|
|
73
|
+
// Content-Encoding so Content-Length matches the body we receive and we don't
|
|
74
|
+
// waste CPU on round-trip re-compression. See https://github.com/pnpm/pnpm/issues/11506
|
|
75
|
+
headers: { 'accept-encoding': 'identity' },
|
|
72
76
|
// The fetch library can retry requests on bad HTTP responses.
|
|
73
77
|
// However, it is not enough to retry on bad HTTP responses only.
|
|
74
78
|
// Requests should also be retried when the tarball's integrity check fails.
|
|
@@ -80,7 +84,11 @@ export function createDownloader(fetchFromRegistry, gotOpts) {
|
|
|
80
84
|
if (res.status !== 200) {
|
|
81
85
|
throw new FetchError({ url, authHeaderValue }, res);
|
|
82
86
|
}
|
|
83
|
-
|
|
87
|
+
// When Content-Encoding is present, Content-Length refers to the encoded form
|
|
88
|
+
// of the data, not the decoded bytes that the fetch implementation yields.
|
|
89
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Encoding
|
|
90
|
+
const isEncoded = isContentEncoded(res.headers.get('content-encoding'));
|
|
91
|
+
const contentLength = !isEncoded && res.headers.has('content-length') && res.headers.get('content-length');
|
|
84
92
|
const parsedLength = typeof contentLength === 'string' ? parseInt(contentLength, 10) : NaN;
|
|
85
93
|
const size = Number.isFinite(parsedLength) && parsedLength >= 0 ? parsedLength : null;
|
|
86
94
|
if (opts.onStart != null) {
|
|
@@ -162,4 +170,15 @@ export function createDownloader(fetchFromRegistry, gotOpts) {
|
|
|
162
170
|
}
|
|
163
171
|
};
|
|
164
172
|
}
|
|
173
|
+
// Per RFC 9110 §8.4, Content-Encoding is a comma-separated list of codings.
|
|
174
|
+
// The response is encoded unless every coding is `identity` (case-insensitive,
|
|
175
|
+
// surrounding whitespace ignored).
|
|
176
|
+
function isContentEncoded(header) {
|
|
177
|
+
if (header == null)
|
|
178
|
+
return false;
|
|
179
|
+
return header
|
|
180
|
+
.split(',')
|
|
181
|
+
.map(coding => coding.trim().toLowerCase())
|
|
182
|
+
.some(coding => coding !== '' && coding !== 'identity');
|
|
183
|
+
}
|
|
165
184
|
//# sourceMappingURL=remoteTarballFetcher.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/fetching.tarball-fetcher",
|
|
3
|
-
"version": "1101.0.
|
|
3
|
+
"version": "1101.0.4",
|
|
4
4
|
"description": "Fetcher for packages hosted as tarballs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
"lodash.throttle": "4.1.1",
|
|
31
31
|
"p-map-values": "^0.1.0",
|
|
32
32
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
33
|
-
"@pnpm/error": "1100.0.0",
|
|
34
33
|
"@pnpm/core-loggers": "1100.0.1",
|
|
35
|
-
"@pnpm/
|
|
34
|
+
"@pnpm/exec.prepare-package": "1100.0.7",
|
|
35
|
+
"@pnpm/error": "1100.0.0",
|
|
36
36
|
"@pnpm/fetching.types": "1100.0.1",
|
|
37
|
-
"@pnpm/fs.packlist": "1100.0.
|
|
38
|
-
"@pnpm/store.index": "1100.
|
|
37
|
+
"@pnpm/fs.packlist": "1100.0.1",
|
|
38
|
+
"@pnpm/store.index": "1100.1.0",
|
|
39
|
+
"@pnpm/fs.graceful-fs": "1100.1.0",
|
|
39
40
|
"@pnpm/types": "1101.0.0",
|
|
40
|
-
"@pnpm/exec.prepare-package": "1100.0.6",
|
|
41
41
|
"@pnpm/fetching.fetcher-base": "1100.1.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@pnpm/logger": "^1001.0.1",
|
|
45
|
-
"@pnpm/worker": "^1100.1.
|
|
45
|
+
"@pnpm/worker": "^1100.1.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@jest/globals": "30.3.0",
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
"ssri": "13.0.1",
|
|
55
55
|
"tempy": "3.0.0",
|
|
56
56
|
"undici": "^7.25.0",
|
|
57
|
-
"@pnpm/
|
|
57
|
+
"@pnpm/fetching.tarball-fetcher": "1101.0.4",
|
|
58
58
|
"@pnpm/network.fetch": "1100.0.2",
|
|
59
|
+
"@pnpm/logger": "1100.0.0",
|
|
59
60
|
"@pnpm/store.cafs-types": "1100.0.1",
|
|
60
|
-
"@pnpm/store.create-cafs-store": "1100.0.5",
|
|
61
|
-
"@pnpm/test-fixtures": "1100.0.0",
|
|
62
61
|
"@pnpm/types": "1101.0.0",
|
|
63
|
-
"@pnpm/
|
|
62
|
+
"@pnpm/test-fixtures": "1100.0.0",
|
|
63
|
+
"@pnpm/store.create-cafs-store": "1100.0.5"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=22.13"
|