Skip to content

Commit b5af015

Browse files
committed
1 parent 14c498d commit b5af015

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

node_modules/make-fetch-happen/lib/cache/entry.js

+25
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ const getMetadata = (request, response, options) => {
9999
}
100100
}
101101

102+
for (const name of options.cacheAdditionalHeaders) {
103+
if (response.headers.has(name)) {
104+
metadata.resHeaders[name] = response.headers.get(name)
105+
}
106+
}
107+
102108
return metadata
103109
}
104110

@@ -331,6 +337,7 @@ class CacheEntry {
331337
// that reads from cacache and attach it to a new Response
332338
const body = new Minipass()
333339
const headers = { ...this.policy.responseHeaders() }
340+
334341
const onResume = () => {
335342
const cacheStream = cacache.get.stream.byDigest(
336343
this.options.cachePath, this.entry.integrity, { memoize: this.options.memoize }
@@ -417,6 +424,24 @@ class CacheEntry {
417424
}
418425
}
419426

427+
for (const name of options.cacheAdditionalHeaders) {
428+
const inMeta = hasOwnProperty(metadata.resHeaders, name)
429+
const inEntry = hasOwnProperty(this.entry.metadata.resHeaders, name)
430+
const inPolicy = hasOwnProperty(this.policy.response.headers, name)
431+
432+
// if the header is in the existing entry, but it is not in the metadata
433+
// then we need to write it to the metadata as this will refresh the on-disk cache
434+
if (!inMeta && inEntry) {
435+
metadata.resHeaders[name] = this.entry.metadata.resHeaders[name]
436+
}
437+
// if the header is in the metadata, but not in the policy, then we need to set
438+
// it in the policy so that it's included in the immediate response. future
439+
// responses will load a new cache entry, so we don't need to change that
440+
if (!inPolicy && inMeta) {
441+
this.policy.response.headers[name] = metadata.resHeaders[name]
442+
}
443+
}
444+
420445
try {
421446
await cacache.index.insert(options.cachePath, this.key, this.entry.integrity, {
422447
size: this.entry.size,

node_modules/make-fetch-happen/lib/options.js

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const configureOptions = (opts) => {
4040
}
4141
}
4242

43+
options.cacheAdditionalHeaders = options.cacheAdditionalHeaders || []
44+
4345
// cacheManager is deprecated, but if it's set and
4446
// cachePath is not we should copy it to the new field
4547
if (options.cacheManager && !options.cachePath) {

node_modules/make-fetch-happen/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "make-fetch-happen",
3-
"version": "11.0.3",
3+
"version": "11.1.0",
44
"description": "Opinionated, caching, retrying fetch client",
55
"main": "lib/index.js",
66
"files": [
@@ -51,7 +51,7 @@
5151
},
5252
"devDependencies": {
5353
"@npmcli/eslint-config": "^4.0.0",
54-
"@npmcli/template-oss": "4.11.3",
54+
"@npmcli/template-oss": "4.13.0",
5555
"nock": "^13.2.4",
5656
"safe-buffer": "^5.2.1",
5757
"standard-version": "^9.3.2",
@@ -72,6 +72,7 @@
7272
},
7373
"templateOSS": {
7474
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
75-
"version": "4.11.3"
75+
"version": "4.13.0",
76+
"publish": "true"
7677
}
7778
}

package-lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"libnpmsearch": "^6.0.2",
118118
"libnpmteam": "^5.0.3",
119119
"libnpmversion": "^4.0.2",
120-
"make-fetch-happen": "^11.0.3",
120+
"make-fetch-happen": "^11.1.0",
121121
"minimatch": "^7.4.3",
122122
"minipass": "^4.2.5",
123123
"minipass-pipeline": "^1.2.4",
@@ -7429,9 +7429,9 @@
74297429
"dev": true
74307430
},
74317431
"node_modules/make-fetch-happen": {
7432-
"version": "11.0.3",
7433-
"resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-11.0.3.tgz",
7434-
"integrity": "sha512-oPLh5m10lRNNZDjJ2kP8UpboUx2uFXVaVweVe/lWut4iHWcQEmfqSVJt2ihZsFI8HbpwyyocaXbCAWf0g1ukIA==",
7432+
"version": "11.1.0",
7433+
"resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-11.1.0.tgz",
7434+
"integrity": "sha512-7ChuOzCb1LzdQZrTy0ky6RsCoMYeM+Fh4cY0+4zsJVhNcH5Q3OJojLY1mGkD0xAhWB29lskECVb6ZopofwjldA==",
74357435
"inBundle": true,
74367436
"dependencies": {
74377437
"agentkeepalive": "^4.2.1",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"libnpmsearch": "^6.0.2",
8787
"libnpmteam": "^5.0.3",
8888
"libnpmversion": "^4.0.2",
89-
"make-fetch-happen": "^11.0.3",
89+
"make-fetch-happen": "^11.1.0",
9090
"minimatch": "^7.4.3",
9191
"minipass": "^4.2.5",
9292
"minipass-pipeline": "^1.2.4",

0 commit comments

Comments
 (0)