Skip to content

Commit

Permalink
deps: make-fetch-happen@11.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Apr 17, 2023
1 parent 14c498d commit b5af015
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
25 changes: 25 additions & 0 deletions node_modules/make-fetch-happen/lib/cache/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ const getMetadata = (request, response, options) => {
}
}

for (const name of options.cacheAdditionalHeaders) {
if (response.headers.has(name)) {
metadata.resHeaders[name] = response.headers.get(name)
}
}

return metadata
}

Expand Down Expand Up @@ -331,6 +337,7 @@ class CacheEntry {
// that reads from cacache and attach it to a new Response
const body = new Minipass()
const headers = { ...this.policy.responseHeaders() }

const onResume = () => {
const cacheStream = cacache.get.stream.byDigest(
this.options.cachePath, this.entry.integrity, { memoize: this.options.memoize }
Expand Down Expand Up @@ -417,6 +424,24 @@ class CacheEntry {
}
}

for (const name of options.cacheAdditionalHeaders) {
const inMeta = hasOwnProperty(metadata.resHeaders, name)
const inEntry = hasOwnProperty(this.entry.metadata.resHeaders, name)
const inPolicy = hasOwnProperty(this.policy.response.headers, name)

// if the header is in the existing entry, but it is not in the metadata
// then we need to write it to the metadata as this will refresh the on-disk cache
if (!inMeta && inEntry) {
metadata.resHeaders[name] = this.entry.metadata.resHeaders[name]
}
// if the header is in the metadata, but not in the policy, then we need to set
// it in the policy so that it's included in the immediate response. future
// responses will load a new cache entry, so we don't need to change that
if (!inPolicy && inMeta) {
this.policy.response.headers[name] = metadata.resHeaders[name]
}
}

try {
await cacache.index.insert(options.cachePath, this.key, this.entry.integrity, {
size: this.entry.size,
Expand Down
2 changes: 2 additions & 0 deletions node_modules/make-fetch-happen/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const configureOptions = (opts) => {
}
}

options.cacheAdditionalHeaders = options.cacheAdditionalHeaders || []

// cacheManager is deprecated, but if it's set and
// cachePath is not we should copy it to the new field
if (options.cacheManager && !options.cachePath) {
Expand Down
7 changes: 4 additions & 3 deletions node_modules/make-fetch-happen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "make-fetch-happen",
"version": "11.0.3",
"version": "11.1.0",
"description": "Opinionated, caching, retrying fetch client",
"main": "lib/index.js",
"files": [
Expand Down Expand Up @@ -51,7 +51,7 @@
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.11.3",
"@npmcli/template-oss": "4.13.0",
"nock": "^13.2.4",
"safe-buffer": "^5.2.1",
"standard-version": "^9.3.2",
Expand All @@ -72,6 +72,7 @@
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.11.3"
"version": "4.13.0",
"publish": "true"
}
}
8 changes: 4 additions & 4 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"libnpmsearch": "^6.0.2",
"libnpmteam": "^5.0.3",
"libnpmversion": "^4.0.2",
"make-fetch-happen": "^11.0.3",
"make-fetch-happen": "^11.1.0",
"minimatch": "^7.4.3",
"minipass": "^4.2.5",
"minipass-pipeline": "^1.2.4",
Expand Down Expand Up @@ -7429,9 +7429,9 @@
"dev": true
},
"node_modules/make-fetch-happen": {
"version": "11.0.3",
"resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-11.0.3.tgz",
"integrity": "sha512-oPLh5m10lRNNZDjJ2kP8UpboUx2uFXVaVweVe/lWut4iHWcQEmfqSVJt2ihZsFI8HbpwyyocaXbCAWf0g1ukIA==",
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-11.1.0.tgz",
"integrity": "sha512-7ChuOzCb1LzdQZrTy0ky6RsCoMYeM+Fh4cY0+4zsJVhNcH5Q3OJojLY1mGkD0xAhWB29lskECVb6ZopofwjldA==",
"inBundle": true,
"dependencies": {
"agentkeepalive": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"libnpmsearch": "^6.0.2",
"libnpmteam": "^5.0.3",
"libnpmversion": "^4.0.2",
"make-fetch-happen": "^11.0.3",
"make-fetch-happen": "^11.1.0",
"minimatch": "^7.4.3",
"minipass": "^4.2.5",
"minipass-pipeline": "^1.2.4",
Expand Down

0 comments on commit b5af015

Please sign in to comment.