Socket
Socket
Sign inDemoInstall

make-fetch-happen

Package Overview
Dependencies
66
Maintainers
6
Versions
105
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.0.3 to 11.1.0

25

lib/cache/entry.js

@@ -102,2 +102,8 @@ const { Request, Response } = require('minipass-fetch')

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

@@ -335,2 +341,3 @@ }

const headers = { ...this.policy.responseHeaders() }
const onResume = () => {

@@ -422,2 +429,20 @@ const cacheStream = cacache.get.stream.byDigest(

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 {

@@ -424,0 +449,0 @@ await cacache.index.insert(options.cachePath, this.key, this.entry.integrity, {

2

lib/options.js

@@ -43,2 +43,4 @@ const dns = require('dns')

options.cacheAdditionalHeaders = options.cacheAdditionalHeaders || []
// cacheManager is deprecated, but if it's set and

@@ -45,0 +47,0 @@ // cachePath is not we should copy it to the new field

7

package.json
{
"name": "make-fetch-happen",
"version": "11.0.3",
"version": "11.1.0",
"description": "Opinionated, caching, retrying fetch client",

@@ -54,3 +54,3 @@ "main": "lib/index.js",

"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.11.3",
"@npmcli/template-oss": "4.13.0",
"nock": "^13.2.4",

@@ -76,4 +76,5 @@ "safe-buffer": "^5.2.1",

"//@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"
}
}

@@ -25,2 +25,3 @@ # make-fetch-happen

* [`opts.cache`](#opts-cache)
* [`opts.cacheAdditionalHeaders`](#opts-cache-additional-headers)
* [`opts.proxy`](#opts-proxy)

@@ -143,2 +144,3 @@ * [`opts.noProxy`](#opts-no-proxy)

* [`opts.cache`](#opts-cache) - `fetch` cache mode. Controls cache *behavior*.
* [`opts.cacheAdditionalHeaders`](#opts-cache-additional-headers) - Store additional headers in the cache
* [`opts.proxy`](#opts-proxy) - Proxy agent

@@ -224,2 +226,30 @@ * [`opts.noProxy`](#opts-no-proxy) - Domain segments to disable proxying for.

#### <a name="opts-cache-additional-headers"></a> `> opts.cacheAdditionalHeaders`
The following headers are always stored in the cache when present:
- `cache-control`
- `content-encoding`
- `content-language`
- `content-type`
- `date`
- `etag`
- `expires`
- `last-modified`
- `link`
- `location`
- `pragma`
- `vary`
This option allows a user to store additional custom headers in the cache.
##### Example
```javascript
fetch('https://registry.npmjs.org/make-fetch-happen', {
cacheAdditionalHeaders: ['my-custom-header'],
})
```
#### <a name="opts-proxy"></a> `> opts.proxy`

@@ -226,0 +256,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc