make-fetch-happen
Advanced tools
Comparing version 5.0.0 to 6.0.0
161
cache.js
'use strict' | ||
const fetch = require('minipass-fetch') | ||
const cacache = require('cacache') | ||
const fetch = require('node-fetch-npm') | ||
const pipe = require('mississippi').pipe | ||
const ssri = require('ssri') | ||
const through = require('mississippi').through | ||
const to = require('mississippi').to | ||
const url = require('url') | ||
const stream = require('stream') | ||
const Minipass = require('minipass') | ||
const MinipassFlush = require('minipass-flush') | ||
const MinipassCollect = require('minipass-collect') | ||
const MinipassPipeline = require('minipass-pipeline') | ||
const MAX_MEM_SIZE = 5 * 1024 * 1024 // 5MB | ||
@@ -63,35 +64,29 @@ | ||
} | ||
let body | ||
const cachePath = this._path | ||
// avoid opening cache file handles until a user actually tries to | ||
// read from it. | ||
if (opts.memoize !== false && info.size > MAX_MEM_SIZE) { | ||
body = new stream.PassThrough() | ||
const realRead = body._read | ||
body._read = function (size) { | ||
body._read = realRead | ||
pipe( | ||
cacache.get.stream.byDigest(cachePath, info.integrity, { | ||
const body = new Minipass() | ||
const notFitInMemory = false && info.size > MAX_MEM_SIZE | ||
const removeOnResume = () => body.removeListener('resume', onResume) | ||
const onResume = | ||
opts.memoize !== notFitInMemory | ||
? () => { | ||
const c = cacache.get.stream.byDigest(cachePath, info.integrity, { | ||
memoize: opts.memoize | ||
}), | ||
body, | ||
err => body.emit(err)) | ||
return realRead.call(this, size) | ||
} | ||
} else { | ||
let readOnce = false | ||
// cacache is much faster at bulk reads | ||
body = new stream.Readable({ | ||
read () { | ||
if (readOnce) return this.push(null) | ||
readOnce = true | ||
}) | ||
c.on('error', err => body.emit('error', err)) | ||
c.pipe(body) | ||
} | ||
: () => { | ||
removeOnResume() | ||
cacache.get.byDigest(cachePath, info.integrity, { | ||
memoize: opts.memoize | ||
}).then(data => { | ||
this.push(data) | ||
this.push(null) | ||
}, err => this.emit('error', err)) | ||
}) | ||
.then(data => body.end(data)) | ||
.catch(err => { | ||
body.emit('error', err) | ||
}) | ||
} | ||
}) | ||
} | ||
body.once('resume', onResume) | ||
body.once('end', () => removeOnResume) | ||
return this.Promise.resolve(new fetch.Response(body, { | ||
@@ -131,61 +126,55 @@ url: req.url, | ||
) | ||
return new this.Promise((resolve, reject) => { | ||
pipe( | ||
cacache.get.stream.byDigest(this._path, info.integrity, cacheOpts), | ||
cacache.put.stream(this._path, cacheKey(req), cacheOpts), | ||
err => err ? reject(err) : resolve(response) | ||
) | ||
}) | ||
}).then(() => response) | ||
return new MinipassPipeline( | ||
cacache.get.stream.byDigest(this._path, info.integrity, cacheOpts), | ||
cacache.put.stream(this._path, cacheKey(req), cacheOpts) | ||
).promise().then(() => response) | ||
}) | ||
} | ||
let buf = [] | ||
let bufSize = 0 | ||
let cacheTargetStream = false | ||
const cachePath = this._path | ||
let cacheStream = to((chunk, enc, cb) => { | ||
if (!cacheTargetStream) { | ||
if (fitInMemory) { | ||
cacheTargetStream = | ||
to({highWaterMark: MAX_MEM_SIZE}, (chunk, enc, cb) => { | ||
buf.push(chunk) | ||
bufSize += chunk.length | ||
cb() | ||
}, done => { | ||
cacache.put( | ||
cachePath, | ||
cacheKey(req), | ||
Buffer.concat(buf, bufSize), | ||
cacheOpts | ||
).then( | ||
() => done(), | ||
done | ||
) | ||
}) | ||
} else { | ||
cacheTargetStream = | ||
cacache.put.stream(cachePath, cacheKey(req), cacheOpts) | ||
} | ||
const oldBody = response.body | ||
const newBody = new MinipassFlush({ | ||
flush () { | ||
return cacheWritePromise | ||
} | ||
cacheTargetStream.write(chunk, enc, cb) | ||
}, done => { | ||
cacheTargetStream ? cacheTargetStream.end(done) : done() | ||
}) | ||
const oldBody = response.body | ||
const newBody = through({highWaterMark: fitInMemory && MAX_MEM_SIZE}) | ||
response.body = newBody | ||
oldBody.once('error', err => newBody.emit('error', err)) | ||
newBody.once('error', err => oldBody.emit('error', err)) | ||
cacheStream.once('error', err => newBody.emit('error', err)) | ||
pipe(oldBody, to((chunk, enc, cb) => { | ||
cacheStream.write(chunk, enc, () => { | ||
newBody.write(chunk, enc, cb) | ||
let cacheWriteResolve, cacheWriteReject | ||
const cacheWritePromise = new Promise((resolve, reject) => { | ||
cacheWriteResolve = resolve | ||
cacheWriteReject = reject | ||
}) | ||
const cachePath = this._path | ||
if (fitInMemory) { | ||
const collecter = new MinipassCollect.PassThrough() | ||
collecter.on('collect', data => { | ||
cacache.put( | ||
cachePath, | ||
cacheKey(req), | ||
data, | ||
cacheOpts | ||
).then(cacheWriteResolve, cacheWriteReject) | ||
}) | ||
}, done => { | ||
cacheStream.end(() => { | ||
newBody.end(() => { | ||
done() | ||
}) | ||
}) | ||
}), err => err && newBody.emit('error', err)) | ||
return response | ||
oldBody | ||
.on('error', er => collecter.emit('error', er)) | ||
.pipe(collecter) | ||
.on('error', er => newBody.emit('error', er)) | ||
.pipe(newBody) | ||
} else { | ||
const tee = new Minipass() | ||
const cacheStream = cacache.put.stream( | ||
cachePath, | ||
cacheKey(req), | ||
cacheOpts | ||
) | ||
tee.pipe(cacheStream) | ||
tee.pipe(newBody) | ||
cacheStream.promise().then(cacheWriteResolve, cacheWriteReject) | ||
oldBody.on('error', er => tee.emit('error', er)) | ||
.pipe(tee) | ||
.on('error', er => newBody.emit('error', er)) | ||
} | ||
return Promise.resolve(new fetch.Response(newBody, response)) | ||
} | ||
@@ -192,0 +181,0 @@ |
289
CHANGELOG.md
@@ -5,4 +5,21 @@ # Change Log | ||
<a name="6.0.0"></a> | ||
# [6.0.0](https://github.com/npm/make-fetch-happen/compare/v5.0.0...v6.0.0) (2019-10-01) | ||
### Bug Fixes | ||
* preserve rfc7234 5.5.4 warnings ([001b91e](https://github.com/npm/make-fetch-happen/commit/001b91e)) | ||
* properly detect thrown HTTP "error" objects ([d7cbeb4](https://github.com/npm/make-fetch-happen/commit/d7cbeb4)) | ||
* safely create synthetic response body for 304 ([bc70f88](https://github.com/npm/make-fetch-happen/commit/bc70f88)) | ||
### Features | ||
* **promises:** refactor bluebird with native promises ([7482d54](https://github.com/npm/make-fetch-happen/commit/7482d54)) | ||
### BREAKING CHANGES | ||
* **streams:** refactor node streams with minipass ([1d7f5a3](https://github.com/npm/make-fetch-happen/commit/1d7f5a3)) | ||
<a name="5.0.0"></a> | ||
# [5.0.0](https://github.com/zkat/make-fetch-happen/compare/v4.0.2...v5.0.0) (2019-07-15) | ||
# [5.0.0](https://github.com/npm/make-fetch-happen/compare/v4.0.2...v5.0.0) (2019-07-15) | ||
@@ -12,3 +29,3 @@ | ||
* cacache@12, no need for uid/gid opts ([fdb956f](https://github.com/zkat/make-fetch-happen/commit/fdb956f)) | ||
* cacache@12, no need for uid/gid opts ([fdb956f](https://github.com/npm/make-fetch-happen/commit/fdb956f)) | ||
@@ -24,3 +41,3 @@ | ||
<a name="4.0.2"></a> | ||
## [4.0.2](https://github.com/zkat/make-fetch-happen/compare/v4.0.1...v4.0.2) (2019-07-02) | ||
## [4.0.2](https://github.com/npm/make-fetch-happen/compare/v4.0.1...v4.0.2) (2019-07-02) | ||
@@ -30,3 +47,3 @@ | ||
<a name="4.0.1"></a> | ||
## [4.0.1](https://github.com/zkat/make-fetch-happen/compare/v4.0.0...v4.0.1) (2018-04-12) | ||
## [4.0.1](https://github.com/npm/make-fetch-happen/compare/v4.0.0...v4.0.1) (2018-04-12) | ||
@@ -36,3 +53,3 @@ | ||
* **integrity:** use new sri.match() for verification ([4f371a0](https://github.com/zkat/make-fetch-happen/commit/4f371a0)) | ||
* **integrity:** use new sri.match() for verification ([4f371a0](https://github.com/npm/make-fetch-happen/commit/4f371a0)) | ||
@@ -42,3 +59,3 @@ | ||
<a name="4.0.0"></a> | ||
# [4.0.0](https://github.com/zkat/make-fetch-happen/compare/v3.0.0...v4.0.0) (2018-04-09) | ||
# [4.0.0](https://github.com/npm/make-fetch-happen/compare/v3.0.0...v4.0.0) (2018-04-09) | ||
@@ -48,3 +65,3 @@ | ||
* drop node@4, add node@9 ([7b0191a](https://github.com/zkat/make-fetch-happen/commit/7b0191a)) | ||
* drop node@4, add node@9 ([7b0191a](https://github.com/npm/make-fetch-happen/commit/7b0191a)) | ||
@@ -59,3 +76,3 @@ | ||
<a name="3.0.0"></a> | ||
# [3.0.0](https://github.com/zkat/make-fetch-happen/compare/v2.6.0...v3.0.0) (2018-03-12) | ||
# [3.0.0](https://github.com/npm/make-fetch-happen/compare/v2.6.0...v3.0.0) (2018-03-12) | ||
@@ -65,4 +82,4 @@ | ||
* **license:** switch to ISC ([#49](https://github.com/zkat/make-fetch-happen/issues/49)) ([bf90c6d](https://github.com/zkat/make-fetch-happen/commit/bf90c6d)) | ||
* **standard:** standard@11 update ([ff0aa70](https://github.com/zkat/make-fetch-happen/commit/ff0aa70)) | ||
* **license:** switch to ISC ([#49](https://github.com/npm/make-fetch-happen/issues/49)) ([bf90c6d](https://github.com/npm/make-fetch-happen/commit/bf90c6d)) | ||
* **standard:** standard@11 update ([ff0aa70](https://github.com/npm/make-fetch-happen/commit/ff0aa70)) | ||
@@ -77,3 +94,3 @@ | ||
<a name="2.6.0"></a> | ||
# [2.6.0](https://github.com/zkat/make-fetch-happen/compare/v2.5.0...v2.6.0) (2017-11-14) | ||
# [2.6.0](https://github.com/npm/make-fetch-happen/compare/v2.5.0...v2.6.0) (2017-11-14) | ||
@@ -83,3 +100,3 @@ | ||
* **integrity:** disable node-fetch compress when checking integrity (#42) ([a7cc74c](https://github.com/zkat/make-fetch-happen/commit/a7cc74c)) | ||
* **integrity:** disable node-fetch compress when checking integrity (#42) ([a7cc74c](https://github.com/npm/make-fetch-happen/commit/a7cc74c)) | ||
@@ -89,3 +106,3 @@ | ||
* **onretry:** Add `options.onRetry` (#48) ([f90ccff](https://github.com/zkat/make-fetch-happen/commit/f90ccff)) | ||
* **onretry:** Add `options.onRetry` (#48) ([f90ccff](https://github.com/npm/make-fetch-happen/commit/f90ccff)) | ||
@@ -95,3 +112,3 @@ | ||
<a name="2.5.0"></a> | ||
# [2.5.0](https://github.com/zkat/make-fetch-happen/compare/v2.4.13...v2.5.0) (2017-08-24) | ||
# [2.5.0](https://github.com/npm/make-fetch-happen/compare/v2.4.13...v2.5.0) (2017-08-24) | ||
@@ -101,3 +118,3 @@ | ||
* **agent:** support timeout durations greater than 30 seconds ([04875ae](https://github.com/zkat/make-fetch-happen/commit/04875ae)), closes [#35](https://github.com/zkat/make-fetch-happen/issues/35) | ||
* **agent:** support timeout durations greater than 30 seconds ([04875ae](https://github.com/npm/make-fetch-happen/commit/04875ae)), closes [#35](https://github.com/npm/make-fetch-happen/issues/35) | ||
@@ -107,3 +124,3 @@ | ||
* **cache:** export cache deletion functionality (#40) ([3da4250](https://github.com/zkat/make-fetch-happen/commit/3da4250)) | ||
* **cache:** export cache deletion functionality (#40) ([3da4250](https://github.com/npm/make-fetch-happen/commit/3da4250)) | ||
@@ -113,3 +130,3 @@ | ||
<a name="2.4.13"></a> | ||
## [2.4.13](https://github.com/zkat/make-fetch-happen/compare/v2.4.12...v2.4.13) (2017-06-29) | ||
## [2.4.13](https://github.com/npm/make-fetch-happen/compare/v2.4.12...v2.4.13) (2017-06-29) | ||
@@ -119,4 +136,4 @@ | ||
* **deps:** bump other deps for bugfixes ([eab8297](https://github.com/zkat/make-fetch-happen/commit/eab8297)) | ||
* **proxy:** bump proxy deps with bugfixes (#32) ([632f860](https://github.com/zkat/make-fetch-happen/commit/632f860)), closes [#32](https://github.com/zkat/make-fetch-happen/issues/32) | ||
* **deps:** bump other deps for bugfixes ([eab8297](https://github.com/npm/make-fetch-happen/commit/eab8297)) | ||
* **proxy:** bump proxy deps with bugfixes (#32) ([632f860](https://github.com/npm/make-fetch-happen/commit/632f860)), closes [#32](https://github.com/npm/make-fetch-happen/issues/32) | ||
@@ -126,3 +143,3 @@ | ||
<a name="2.4.12"></a> | ||
## [2.4.12](https://github.com/zkat/make-fetch-happen/compare/v2.4.11...v2.4.12) (2017-06-06) | ||
## [2.4.12](https://github.com/npm/make-fetch-happen/compare/v2.4.11...v2.4.12) (2017-06-06) | ||
@@ -132,3 +149,3 @@ | ||
* **cache:** encode x-local-cache-etc headers to be header-safe ([dc9fb1b](https://github.com/zkat/make-fetch-happen/commit/dc9fb1b)) | ||
* **cache:** encode x-local-cache-etc headers to be header-safe ([dc9fb1b](https://github.com/npm/make-fetch-happen/commit/dc9fb1b)) | ||
@@ -138,3 +155,3 @@ | ||
<a name="2.4.11"></a> | ||
## [2.4.11](https://github.com/zkat/make-fetch-happen/compare/v2.4.10...v2.4.11) (2017-06-05) | ||
## [2.4.11](https://github.com/npm/make-fetch-happen/compare/v2.4.10...v2.4.11) (2017-06-05) | ||
@@ -144,3 +161,3 @@ | ||
* **deps:** bump deps with ssri fix ([bef1994](https://github.com/zkat/make-fetch-happen/commit/bef1994)) | ||
* **deps:** bump deps with ssri fix ([bef1994](https://github.com/npm/make-fetch-happen/commit/bef1994)) | ||
@@ -150,3 +167,3 @@ | ||
<a name="2.4.10"></a> | ||
## [2.4.10](https://github.com/zkat/make-fetch-happen/compare/v2.4.9...v2.4.10) (2017-05-31) | ||
## [2.4.10](https://github.com/npm/make-fetch-happen/compare/v2.4.9...v2.4.10) (2017-05-31) | ||
@@ -156,4 +173,4 @@ | ||
* **deps:** bump dep versions with bugfixes ([0af4003](https://github.com/zkat/make-fetch-happen/commit/0af4003)) | ||
* **proxy:** use auth parameter for proxy authentication (#30) ([c687306](https://github.com/zkat/make-fetch-happen/commit/c687306)) | ||
* **deps:** bump dep versions with bugfixes ([0af4003](https://github.com/npm/make-fetch-happen/commit/0af4003)) | ||
* **proxy:** use auth parameter for proxy authentication (#30) ([c687306](https://github.com/npm/make-fetch-happen/commit/c687306)) | ||
@@ -163,3 +180,3 @@ | ||
<a name="2.4.9"></a> | ||
## [2.4.9](https://github.com/zkat/make-fetch-happen/compare/v2.4.8...v2.4.9) (2017-05-25) | ||
## [2.4.9](https://github.com/npm/make-fetch-happen/compare/v2.4.8...v2.4.9) (2017-05-25) | ||
@@ -169,3 +186,3 @@ | ||
* **cache:** use the passed-in promise for resolving cache stuff ([4c46257](https://github.com/zkat/make-fetch-happen/commit/4c46257)) | ||
* **cache:** use the passed-in promise for resolving cache stuff ([4c46257](https://github.com/npm/make-fetch-happen/commit/4c46257)) | ||
@@ -175,3 +192,3 @@ | ||
<a name="2.4.8"></a> | ||
## [2.4.8](https://github.com/zkat/make-fetch-happen/compare/v2.4.7...v2.4.8) (2017-05-25) | ||
## [2.4.8](https://github.com/npm/make-fetch-happen/compare/v2.4.7...v2.4.8) (2017-05-25) | ||
@@ -181,3 +198,3 @@ | ||
* **cache:** pass uid/gid/Promise through to cache ([a847c92](https://github.com/zkat/make-fetch-happen/commit/a847c92)) | ||
* **cache:** pass uid/gid/Promise through to cache ([a847c92](https://github.com/npm/make-fetch-happen/commit/a847c92)) | ||
@@ -187,3 +204,3 @@ | ||
<a name="2.4.7"></a> | ||
## [2.4.7](https://github.com/zkat/make-fetch-happen/compare/v2.4.6...v2.4.7) (2017-05-24) | ||
## [2.4.7](https://github.com/npm/make-fetch-happen/compare/v2.4.6...v2.4.7) (2017-05-24) | ||
@@ -193,3 +210,3 @@ | ||
* **deps:** pull in various fixes from deps ([fc2a587](https://github.com/zkat/make-fetch-happen/commit/fc2a587)) | ||
* **deps:** pull in various fixes from deps ([fc2a587](https://github.com/npm/make-fetch-happen/commit/fc2a587)) | ||
@@ -199,3 +216,3 @@ | ||
<a name="2.4.6"></a> | ||
## [2.4.6](https://github.com/zkat/make-fetch-happen/compare/v2.4.5...v2.4.6) (2017-05-24) | ||
## [2.4.6](https://github.com/npm/make-fetch-happen/compare/v2.4.5...v2.4.6) (2017-05-24) | ||
@@ -205,5 +222,5 @@ | ||
* **proxy:** choose agent for http(s)-proxy by protocol of destUrl ([ea4832a](https://github.com/zkat/make-fetch-happen/commit/ea4832a)) | ||
* **proxy:** make socks proxy working ([1de810a](https://github.com/zkat/make-fetch-happen/commit/1de810a)) | ||
* **proxy:** revert previous proxy solution ([563b0d8](https://github.com/zkat/make-fetch-happen/commit/563b0d8)) | ||
* **proxy:** choose agent for http(s)-proxy by protocol of destUrl ([ea4832a](https://github.com/npm/make-fetch-happen/commit/ea4832a)) | ||
* **proxy:** make socks proxy working ([1de810a](https://github.com/npm/make-fetch-happen/commit/1de810a)) | ||
* **proxy:** revert previous proxy solution ([563b0d8](https://github.com/npm/make-fetch-happen/commit/563b0d8)) | ||
@@ -213,3 +230,3 @@ | ||
<a name="2.4.5"></a> | ||
## [2.4.5](https://github.com/zkat/make-fetch-happen/compare/v2.4.4...v2.4.5) (2017-05-24) | ||
## [2.4.5](https://github.com/npm/make-fetch-happen/compare/v2.4.4...v2.4.5) (2017-05-24) | ||
@@ -219,3 +236,3 @@ | ||
* **proxy:** use the destination url when determining agent ([1a714e7](https://github.com/zkat/make-fetch-happen/commit/1a714e7)) | ||
* **proxy:** use the destination url when determining agent ([1a714e7](https://github.com/npm/make-fetch-happen/commit/1a714e7)) | ||
@@ -225,3 +242,3 @@ | ||
<a name="2.4.4"></a> | ||
## [2.4.4](https://github.com/zkat/make-fetch-happen/compare/v2.4.3...v2.4.4) (2017-05-23) | ||
## [2.4.4](https://github.com/npm/make-fetch-happen/compare/v2.4.3...v2.4.4) (2017-05-23) | ||
@@ -231,3 +248,3 @@ | ||
* **redirect:** handle redirects explicitly (#27) ([4c4af54](https://github.com/zkat/make-fetch-happen/commit/4c4af54)) | ||
* **redirect:** handle redirects explicitly (#27) ([4c4af54](https://github.com/npm/make-fetch-happen/commit/4c4af54)) | ||
@@ -237,3 +254,3 @@ | ||
<a name="2.4.3"></a> | ||
## [2.4.3](https://github.com/zkat/make-fetch-happen/compare/v2.4.2...v2.4.3) (2017-05-06) | ||
## [2.4.3](https://github.com/npm/make-fetch-happen/compare/v2.4.2...v2.4.3) (2017-05-06) | ||
@@ -243,3 +260,3 @@ | ||
* **redirect:** redirects now delete authorization if hosts fail to match ([c071805](https://github.com/zkat/make-fetch-happen/commit/c071805)) | ||
* **redirect:** redirects now delete authorization if hosts fail to match ([c071805](https://github.com/npm/make-fetch-happen/commit/c071805)) | ||
@@ -249,3 +266,3 @@ | ||
<a name="2.4.2"></a> | ||
## [2.4.2](https://github.com/zkat/make-fetch-happen/compare/v2.4.1...v2.4.2) (2017-05-04) | ||
## [2.4.2](https://github.com/npm/make-fetch-happen/compare/v2.4.1...v2.4.2) (2017-05-04) | ||
@@ -255,4 +272,4 @@ | ||
* **cache:** reduce race condition window by checking for content ([24544b1](https://github.com/zkat/make-fetch-happen/commit/24544b1)) | ||
* **match:** Rewrite the conditional stream logic (#25) ([66bba4b](https://github.com/zkat/make-fetch-happen/commit/66bba4b)) | ||
* **cache:** reduce race condition window by checking for content ([24544b1](https://github.com/npm/make-fetch-happen/commit/24544b1)) | ||
* **match:** Rewrite the conditional stream logic (#25) ([66bba4b](https://github.com/npm/make-fetch-happen/commit/66bba4b)) | ||
@@ -262,3 +279,3 @@ | ||
<a name="2.4.1"></a> | ||
## [2.4.1](https://github.com/zkat/make-fetch-happen/compare/v2.4.0...v2.4.1) (2017-04-28) | ||
## [2.4.1](https://github.com/npm/make-fetch-happen/compare/v2.4.0...v2.4.1) (2017-04-28) | ||
@@ -268,3 +285,3 @@ | ||
* **memoization:** missed spots + allow passthrough of memo objs ([ac0cd12](https://github.com/zkat/make-fetch-happen/commit/ac0cd12)) | ||
* **memoization:** missed spots + allow passthrough of memo objs ([ac0cd12](https://github.com/npm/make-fetch-happen/commit/ac0cd12)) | ||
@@ -274,3 +291,3 @@ | ||
<a name="2.4.0"></a> | ||
# [2.4.0](https://github.com/zkat/make-fetch-happen/compare/v2.3.0...v2.4.0) (2017-04-28) | ||
# [2.4.0](https://github.com/npm/make-fetch-happen/compare/v2.3.0...v2.4.0) (2017-04-28) | ||
@@ -280,3 +297,3 @@ | ||
* **memoize:** cacache had a broken memoizer ([8a9ed4c](https://github.com/zkat/make-fetch-happen/commit/8a9ed4c)) | ||
* **memoize:** cacache had a broken memoizer ([8a9ed4c](https://github.com/npm/make-fetch-happen/commit/8a9ed4c)) | ||
@@ -286,3 +303,3 @@ | ||
* **memoization:** only slurp stuff into memory if opts.memoize is not false ([0744adc](https://github.com/zkat/make-fetch-happen/commit/0744adc)) | ||
* **memoization:** only slurp stuff into memory if opts.memoize is not false ([0744adc](https://github.com/npm/make-fetch-happen/commit/0744adc)) | ||
@@ -292,3 +309,3 @@ | ||
<a name="2.3.0"></a> | ||
# [2.3.0](https://github.com/zkat/make-fetch-happen/compare/v2.2.6...v2.3.0) (2017-04-27) | ||
# [2.3.0](https://github.com/npm/make-fetch-happen/compare/v2.2.6...v2.3.0) (2017-04-27) | ||
@@ -298,4 +315,4 @@ | ||
* **agent:** added opts.strictSSL and opts.localAddress ([c35015a](https://github.com/zkat/make-fetch-happen/commit/c35015a)) | ||
* **proxy:** Added opts.noProxy and NO_PROXY support ([f45c915](https://github.com/zkat/make-fetch-happen/commit/f45c915)) | ||
* **agent:** added opts.strictSSL and opts.localAddress ([c35015a](https://github.com/npm/make-fetch-happen/commit/c35015a)) | ||
* **proxy:** Added opts.noProxy and NO_PROXY support ([f45c915](https://github.com/npm/make-fetch-happen/commit/f45c915)) | ||
@@ -305,3 +322,3 @@ | ||
<a name="2.2.6"></a> | ||
## [2.2.6](https://github.com/zkat/make-fetch-happen/compare/v2.2.5...v2.2.6) (2017-04-26) | ||
## [2.2.6](https://github.com/npm/make-fetch-happen/compare/v2.2.5...v2.2.6) (2017-04-26) | ||
@@ -311,4 +328,4 @@ | ||
* **agent:** check uppercase & lowercase proxy env (#24) ([acf2326](https://github.com/zkat/make-fetch-happen/commit/acf2326)), closes [#22](https://github.com/zkat/make-fetch-happen/issues/22) | ||
* **deps:** switch to node-fetch-npm and stop bundling ([3db603b](https://github.com/zkat/make-fetch-happen/commit/3db603b)) | ||
* **agent:** check uppercase & lowercase proxy env (#24) ([acf2326](https://github.com/npm/make-fetch-happen/commit/acf2326)), closes [#22](https://github.com/npm/make-fetch-happen/issues/22) | ||
* **deps:** switch to node-fetch-npm and stop bundling ([3db603b](https://github.com/npm/make-fetch-happen/commit/3db603b)) | ||
@@ -318,3 +335,3 @@ | ||
<a name="2.2.5"></a> | ||
## [2.2.5](https://github.com/zkat/make-fetch-happen/compare/v2.2.4...v2.2.5) (2017-04-23) | ||
## [2.2.5](https://github.com/npm/make-fetch-happen/compare/v2.2.4...v2.2.5) (2017-04-23) | ||
@@ -324,3 +341,3 @@ | ||
* **deps:** bump cacache and use its size feature ([926c1d3](https://github.com/zkat/make-fetch-happen/commit/926c1d3)) | ||
* **deps:** bump cacache and use its size feature ([926c1d3](https://github.com/npm/make-fetch-happen/commit/926c1d3)) | ||
@@ -330,3 +347,3 @@ | ||
<a name="2.2.4"></a> | ||
## [2.2.4](https://github.com/zkat/make-fetch-happen/compare/v2.2.3...v2.2.4) (2017-04-18) | ||
## [2.2.4](https://github.com/npm/make-fetch-happen/compare/v2.2.3...v2.2.4) (2017-04-18) | ||
@@ -336,3 +353,3 @@ | ||
* **integrity:** hash verification issues fixed ([07f9402](https://github.com/zkat/make-fetch-happen/commit/07f9402)) | ||
* **integrity:** hash verification issues fixed ([07f9402](https://github.com/npm/make-fetch-happen/commit/07f9402)) | ||
@@ -342,3 +359,3 @@ | ||
<a name="2.2.3"></a> | ||
## [2.2.3](https://github.com/zkat/make-fetch-happen/compare/v2.2.2...v2.2.3) (2017-04-18) | ||
## [2.2.3](https://github.com/npm/make-fetch-happen/compare/v2.2.2...v2.2.3) (2017-04-18) | ||
@@ -348,4 +365,4 @@ | ||
* **staleness:** responses older than 8h were never stale :< ([b54dd75](https://github.com/zkat/make-fetch-happen/commit/b54dd75)) | ||
* **warning:** remove spurious warning, make format more spec-compliant ([2e4f6bb](https://github.com/zkat/make-fetch-happen/commit/2e4f6bb)) | ||
* **staleness:** responses older than 8h were never stale :< ([b54dd75](https://github.com/npm/make-fetch-happen/commit/b54dd75)) | ||
* **warning:** remove spurious warning, make format more spec-compliant ([2e4f6bb](https://github.com/npm/make-fetch-happen/commit/2e4f6bb)) | ||
@@ -355,3 +372,3 @@ | ||
<a name="2.2.2"></a> | ||
## [2.2.2](https://github.com/zkat/make-fetch-happen/compare/v2.2.1...v2.2.2) (2017-04-12) | ||
## [2.2.2](https://github.com/npm/make-fetch-happen/compare/v2.2.1...v2.2.2) (2017-04-12) | ||
@@ -361,3 +378,3 @@ | ||
* **retry:** stop retrying 404s ([6fafd53](https://github.com/zkat/make-fetch-happen/commit/6fafd53)) | ||
* **retry:** stop retrying 404s ([6fafd53](https://github.com/npm/make-fetch-happen/commit/6fafd53)) | ||
@@ -367,3 +384,3 @@ | ||
<a name="2.2.1"></a> | ||
## [2.2.1](https://github.com/zkat/make-fetch-happen/compare/v2.2.0...v2.2.1) (2017-04-10) | ||
## [2.2.1](https://github.com/npm/make-fetch-happen/compare/v2.2.0...v2.2.1) (2017-04-10) | ||
@@ -373,3 +390,3 @@ | ||
* **deps:** move test-only deps to devDeps ([2daaf80](https://github.com/zkat/make-fetch-happen/commit/2daaf80)) | ||
* **deps:** move test-only deps to devDeps ([2daaf80](https://github.com/npm/make-fetch-happen/commit/2daaf80)) | ||
@@ -379,3 +396,3 @@ | ||
<a name="2.2.0"></a> | ||
# [2.2.0](https://github.com/zkat/make-fetch-happen/compare/v2.1.0...v2.2.0) (2017-04-09) | ||
# [2.2.0](https://github.com/npm/make-fetch-happen/compare/v2.1.0...v2.2.0) (2017-04-09) | ||
@@ -385,3 +402,3 @@ | ||
* **cache:** treat caches as private ([57b7dc2](https://github.com/zkat/make-fetch-happen/commit/57b7dc2)) | ||
* **cache:** treat caches as private ([57b7dc2](https://github.com/npm/make-fetch-happen/commit/57b7dc2)) | ||
@@ -391,3 +408,3 @@ | ||
* **retry:** accept shorthand retry settings ([dfed69d](https://github.com/zkat/make-fetch-happen/commit/dfed69d)) | ||
* **retry:** accept shorthand retry settings ([dfed69d](https://github.com/npm/make-fetch-happen/commit/dfed69d)) | ||
@@ -397,3 +414,3 @@ | ||
<a name="2.1.0"></a> | ||
# [2.1.0](https://github.com/zkat/make-fetch-happen/compare/v2.0.4...v2.1.0) (2017-04-09) | ||
# [2.1.0](https://github.com/npm/make-fetch-happen/compare/v2.0.4...v2.1.0) (2017-04-09) | ||
@@ -403,3 +420,3 @@ | ||
* **cache:** cache now obeys Age and a variety of other things (#13) ([7b9652d](https://github.com/zkat/make-fetch-happen/commit/7b9652d)) | ||
* **cache:** cache now obeys Age and a variety of other things (#13) ([7b9652d](https://github.com/npm/make-fetch-happen/commit/7b9652d)) | ||
@@ -409,3 +426,3 @@ | ||
<a name="2.0.4"></a> | ||
## [2.0.4](https://github.com/zkat/make-fetch-happen/compare/v2.0.3...v2.0.4) (2017-04-09) | ||
## [2.0.4](https://github.com/npm/make-fetch-happen/compare/v2.0.3...v2.0.4) (2017-04-09) | ||
@@ -415,3 +432,3 @@ | ||
* **agent:** accept Request as fetch input, not just strings ([b71669a](https://github.com/zkat/make-fetch-happen/commit/b71669a)) | ||
* **agent:** accept Request as fetch input, not just strings ([b71669a](https://github.com/npm/make-fetch-happen/commit/b71669a)) | ||
@@ -421,3 +438,3 @@ | ||
<a name="2.0.3"></a> | ||
## [2.0.3](https://github.com/zkat/make-fetch-happen/compare/v2.0.2...v2.0.3) (2017-04-09) | ||
## [2.0.3](https://github.com/npm/make-fetch-happen/compare/v2.0.2...v2.0.3) (2017-04-09) | ||
@@ -427,3 +444,3 @@ | ||
* **deps:** seriously ([c29e7e7](https://github.com/zkat/make-fetch-happen/commit/c29e7e7)) | ||
* **deps:** seriously ([c29e7e7](https://github.com/npm/make-fetch-happen/commit/c29e7e7)) | ||
@@ -433,3 +450,3 @@ | ||
<a name="2.0.2"></a> | ||
## [2.0.2](https://github.com/zkat/make-fetch-happen/compare/v2.0.1...v2.0.2) (2017-04-09) | ||
## [2.0.2](https://github.com/npm/make-fetch-happen/compare/v2.0.1...v2.0.2) (2017-04-09) | ||
@@ -439,3 +456,3 @@ | ||
* **deps:** use bundleDeps instead ([c36ebf0](https://github.com/zkat/make-fetch-happen/commit/c36ebf0)) | ||
* **deps:** use bundleDeps instead ([c36ebf0](https://github.com/npm/make-fetch-happen/commit/c36ebf0)) | ||
@@ -445,3 +462,3 @@ | ||
<a name="2.0.1"></a> | ||
## [2.0.1](https://github.com/zkat/make-fetch-happen/compare/v2.0.0...v2.0.1) (2017-04-09) | ||
## [2.0.1](https://github.com/npm/make-fetch-happen/compare/v2.0.0...v2.0.1) (2017-04-09) | ||
@@ -451,3 +468,3 @@ | ||
* **deps:** make sure node-fetch tarball included in release ([3bf49d1](https://github.com/zkat/make-fetch-happen/commit/3bf49d1)) | ||
* **deps:** make sure node-fetch tarball included in release ([3bf49d1](https://github.com/npm/make-fetch-happen/commit/3bf49d1)) | ||
@@ -457,3 +474,3 @@ | ||
<a name="2.0.0"></a> | ||
# [2.0.0](https://github.com/zkat/make-fetch-happen/compare/v1.7.0...v2.0.0) (2017-04-09) | ||
# [2.0.0](https://github.com/npm/make-fetch-happen/compare/v1.7.0...v2.0.0) (2017-04-09) | ||
@@ -463,4 +480,4 @@ | ||
* **deps:** manually pull in newer node-fetch to avoid babel prod dep ([66e5e87](https://github.com/zkat/make-fetch-happen/commit/66e5e87)) | ||
* **retry:** be more specific about when we retry ([a47b782](https://github.com/zkat/make-fetch-happen/commit/a47b782)) | ||
* **deps:** manually pull in newer node-fetch to avoid babel prod dep ([66e5e87](https://github.com/npm/make-fetch-happen/commit/66e5e87)) | ||
* **retry:** be more specific about when we retry ([a47b782](https://github.com/npm/make-fetch-happen/commit/a47b782)) | ||
@@ -470,3 +487,3 @@ | ||
* **agent:** add ca/cert/key support to auto-agent (#15) ([57585a7](https://github.com/zkat/make-fetch-happen/commit/57585a7)) | ||
* **agent:** add ca/cert/key support to auto-agent (#15) ([57585a7](https://github.com/npm/make-fetch-happen/commit/57585a7)) | ||
@@ -486,3 +503,3 @@ | ||
<a name="1.7.0"></a> | ||
# [1.7.0](https://github.com/zkat/make-fetch-happen/compare/v1.6.0...v1.7.0) (2017-04-08) | ||
# [1.7.0](https://github.com/npm/make-fetch-happen/compare/v1.6.0...v1.7.0) (2017-04-08) | ||
@@ -492,3 +509,3 @@ | ||
* **cache:** add useful headers to inform users about cached data ([9bd7b00](https://github.com/zkat/make-fetch-happen/commit/9bd7b00)) | ||
* **cache:** add useful headers to inform users about cached data ([9bd7b00](https://github.com/npm/make-fetch-happen/commit/9bd7b00)) | ||
@@ -498,3 +515,3 @@ | ||
<a name="1.6.0"></a> | ||
# [1.6.0](https://github.com/zkat/make-fetch-happen/compare/v1.5.1...v1.6.0) (2017-04-06) | ||
# [1.6.0](https://github.com/npm/make-fetch-happen/compare/v1.5.1...v1.6.0) (2017-04-06) | ||
@@ -504,3 +521,3 @@ | ||
* **agent:** better, keepalive-supporting, default http agents ([16277f6](https://github.com/zkat/make-fetch-happen/commit/16277f6)) | ||
* **agent:** better, keepalive-supporting, default http agents ([16277f6](https://github.com/npm/make-fetch-happen/commit/16277f6)) | ||
@@ -510,3 +527,3 @@ | ||
<a name="1.5.1"></a> | ||
## [1.5.1](https://github.com/zkat/make-fetch-happen/compare/v1.5.0...v1.5.1) (2017-04-05) | ||
## [1.5.1](https://github.com/npm/make-fetch-happen/compare/v1.5.0...v1.5.1) (2017-04-05) | ||
@@ -516,4 +533,4 @@ | ||
* **cache:** bump cacache for its fixed error messages ([2f2b916](https://github.com/zkat/make-fetch-happen/commit/2f2b916)) | ||
* **cache:** fix handling of errors in cache reads ([5729222](https://github.com/zkat/make-fetch-happen/commit/5729222)) | ||
* **cache:** bump cacache for its fixed error messages ([2f2b916](https://github.com/npm/make-fetch-happen/commit/2f2b916)) | ||
* **cache:** fix handling of errors in cache reads ([5729222](https://github.com/npm/make-fetch-happen/commit/5729222)) | ||
@@ -523,3 +540,3 @@ | ||
<a name="1.5.0"></a> | ||
# [1.5.0](https://github.com/zkat/make-fetch-happen/compare/v1.4.0...v1.5.0) (2017-04-04) | ||
# [1.5.0](https://github.com/npm/make-fetch-happen/compare/v1.4.0...v1.5.0) (2017-04-04) | ||
@@ -529,3 +546,3 @@ | ||
* **retry:** retry requests on 408 timeouts, too ([8d8b5bd](https://github.com/zkat/make-fetch-happen/commit/8d8b5bd)) | ||
* **retry:** retry requests on 408 timeouts, too ([8d8b5bd](https://github.com/npm/make-fetch-happen/commit/8d8b5bd)) | ||
@@ -535,3 +552,3 @@ | ||
<a name="1.4.0"></a> | ||
# [1.4.0](https://github.com/zkat/make-fetch-happen/compare/v1.3.1...v1.4.0) (2017-04-04) | ||
# [1.4.0](https://github.com/npm/make-fetch-happen/compare/v1.3.1...v1.4.0) (2017-04-04) | ||
@@ -541,3 +558,3 @@ | ||
* **cache:** stop relying on BB.catch ([2b04494](https://github.com/zkat/make-fetch-happen/commit/2b04494)) | ||
* **cache:** stop relying on BB.catch ([2b04494](https://github.com/npm/make-fetch-happen/commit/2b04494)) | ||
@@ -547,3 +564,3 @@ | ||
* **retry:** report retry attempt number as extra header ([fd50927](https://github.com/zkat/make-fetch-happen/commit/fd50927)) | ||
* **retry:** report retry attempt number as extra header ([fd50927](https://github.com/npm/make-fetch-happen/commit/fd50927)) | ||
@@ -553,3 +570,3 @@ | ||
<a name="1.3.1"></a> | ||
## [1.3.1](https://github.com/zkat/make-fetch-happen/compare/v1.3.0...v1.3.1) (2017-04-04) | ||
## [1.3.1](https://github.com/npm/make-fetch-happen/compare/v1.3.0...v1.3.1) (2017-04-04) | ||
@@ -559,3 +576,3 @@ | ||
* **cache:** pretend cache entry is missing on ENOENT ([9c2bb26](https://github.com/zkat/make-fetch-happen/commit/9c2bb26)) | ||
* **cache:** pretend cache entry is missing on ENOENT ([9c2bb26](https://github.com/npm/make-fetch-happen/commit/9c2bb26)) | ||
@@ -565,3 +582,3 @@ | ||
<a name="1.3.0"></a> | ||
# [1.3.0](https://github.com/zkat/make-fetch-happen/compare/v1.2.1...v1.3.0) (2017-04-04) | ||
# [1.3.0](https://github.com/npm/make-fetch-happen/compare/v1.2.1...v1.3.0) (2017-04-04) | ||
@@ -571,3 +588,3 @@ | ||
* **cache:** if metadata is missing for some odd reason, ignore the entry ([a021a6b](https://github.com/zkat/make-fetch-happen/commit/a021a6b)) | ||
* **cache:** if metadata is missing for some odd reason, ignore the entry ([a021a6b](https://github.com/npm/make-fetch-happen/commit/a021a6b)) | ||
@@ -577,4 +594,4 @@ | ||
* **cache:** add special headers when request was loaded straight from cache ([8a7dbd1](https://github.com/zkat/make-fetch-happen/commit/8a7dbd1)) | ||
* **cache:** allow configuring algorithms to be calculated on insertion ([bf4a0f2](https://github.com/zkat/make-fetch-happen/commit/bf4a0f2)) | ||
* **cache:** add special headers when request was loaded straight from cache ([8a7dbd1](https://github.com/npm/make-fetch-happen/commit/8a7dbd1)) | ||
* **cache:** allow configuring algorithms to be calculated on insertion ([bf4a0f2](https://github.com/npm/make-fetch-happen/commit/bf4a0f2)) | ||
@@ -584,3 +601,3 @@ | ||
<a name="1.2.1"></a> | ||
## [1.2.1](https://github.com/zkat/make-fetch-happen/compare/v1.2.0...v1.2.1) (2017-04-03) | ||
## [1.2.1](https://github.com/npm/make-fetch-happen/compare/v1.2.0...v1.2.1) (2017-04-03) | ||
@@ -590,3 +607,3 @@ | ||
* **integrity:** update cacache and ssri and change EBADCHECKSUM -> EINTEGRITY ([b6cf6f6](https://github.com/zkat/make-fetch-happen/commit/b6cf6f6)) | ||
* **integrity:** update cacache and ssri and change EBADCHECKSUM -> EINTEGRITY ([b6cf6f6](https://github.com/npm/make-fetch-happen/commit/b6cf6f6)) | ||
@@ -596,3 +613,3 @@ | ||
<a name="1.2.0"></a> | ||
# [1.2.0](https://github.com/zkat/make-fetch-happen/compare/v1.1.0...v1.2.0) (2017-04-03) | ||
# [1.2.0](https://github.com/npm/make-fetch-happen/compare/v1.1.0...v1.2.0) (2017-04-03) | ||
@@ -602,3 +619,3 @@ | ||
* **integrity:** full Subresource Integrity support (#10) ([a590159](https://github.com/zkat/make-fetch-happen/commit/a590159)) | ||
* **integrity:** full Subresource Integrity support (#10) ([a590159](https://github.com/npm/make-fetch-happen/commit/a590159)) | ||
@@ -608,3 +625,3 @@ | ||
<a name="1.1.0"></a> | ||
# [1.1.0](https://github.com/zkat/make-fetch-happen/compare/v1.0.1...v1.1.0) (2017-04-01) | ||
# [1.1.0](https://github.com/npm/make-fetch-happen/compare/v1.0.1...v1.1.0) (2017-04-01) | ||
@@ -614,3 +631,3 @@ | ||
* **opts:** fetch.defaults() for default options ([522a65e](https://github.com/zkat/make-fetch-happen/commit/522a65e)) | ||
* **opts:** fetch.defaults() for default options ([522a65e](https://github.com/npm/make-fetch-happen/commit/522a65e)) | ||
@@ -620,3 +637,3 @@ | ||
<a name="1.0.1"></a> | ||
## [1.0.1](https://github.com/zkat/make-fetch-happen/compare/v1.0.0...v1.0.1) (2017-04-01) | ||
## [1.0.1](https://github.com/npm/make-fetch-happen/compare/v1.0.0...v1.0.1) (2017-04-01) | ||
@@ -631,27 +648,27 @@ | ||
* **cache:** default on cache-control header ([b872a2c](https://github.com/zkat/make-fetch-happen/commit/b872a2c)) | ||
* standard stuff and cache matching ([753f2c2](https://github.com/zkat/make-fetch-happen/commit/753f2c2)) | ||
* **agent:** nudge around things with opts.agent ([ed62b57](https://github.com/zkat/make-fetch-happen/commit/ed62b57)) | ||
* **agent:** {agent: false} has special behavior ([b8cc923](https://github.com/zkat/make-fetch-happen/commit/b8cc923)) | ||
* **cache:** invalidation on non-GET ([fe78fac](https://github.com/zkat/make-fetch-happen/commit/fe78fac)) | ||
* **cache:** make force-cache and only-if-cached work as expected ([f50e9df](https://github.com/zkat/make-fetch-happen/commit/f50e9df)) | ||
* **cache:** more spec compliance ([d5a56db](https://github.com/zkat/make-fetch-happen/commit/d5a56db)) | ||
* **cache:** only cache 200 gets ([0abb25a](https://github.com/zkat/make-fetch-happen/commit/0abb25a)) | ||
* **cache:** only load cache code if cache opt is a string ([250fcd5](https://github.com/zkat/make-fetch-happen/commit/250fcd5)) | ||
* **cache:** oops ([e3fa15a](https://github.com/zkat/make-fetch-happen/commit/e3fa15a)) | ||
* **cache:** refactored warning removal into main file ([5b0a9f9](https://github.com/zkat/make-fetch-happen/commit/5b0a9f9)) | ||
* **cache:** req constructor no longer needed in Cache ([5b74cbc](https://github.com/zkat/make-fetch-happen/commit/5b74cbc)) | ||
* **cache:** standard fetch api calls cacheMode "cache" ([6fba805](https://github.com/zkat/make-fetch-happen/commit/6fba805)) | ||
* **cache:** was using wrong method for non-GET/HEAD cache invalidation ([810763a](https://github.com/zkat/make-fetch-happen/commit/810763a)) | ||
* **caching:** a bunch of cache-related fixes ([8ebda1d](https://github.com/zkat/make-fetch-happen/commit/8ebda1d)) | ||
* **deps:** `cacache[@6](https://github.com/6).3.0` - race condition fixes ([9528442](https://github.com/zkat/make-fetch-happen/commit/9528442)) | ||
* **freshness:** fix regex for cacheControl matching ([070db86](https://github.com/zkat/make-fetch-happen/commit/070db86)) | ||
* **freshness:** fixed default freshness heuristic value ([5d29e88](https://github.com/zkat/make-fetch-happen/commit/5d29e88)) | ||
* **logging:** remove console.log calls ([a1d0a47](https://github.com/zkat/make-fetch-happen/commit/a1d0a47)) | ||
* **method:** node-fetch guarantees uppercase ([a1d68d6](https://github.com/zkat/make-fetch-happen/commit/a1d68d6)) | ||
* **opts:** simplified opts handling ([516fd6e](https://github.com/zkat/make-fetch-happen/commit/516fd6e)) | ||
* **proxy:** pass proxy option directly to ProxyAgent ([3398460](https://github.com/zkat/make-fetch-happen/commit/3398460)) | ||
* **retry:** false -> {retries: 0} ([297fbb6](https://github.com/zkat/make-fetch-happen/commit/297fbb6)) | ||
* **retry:** only retry put if body is not a stream ([a24e599](https://github.com/zkat/make-fetch-happen/commit/a24e599)) | ||
* **retry:** skip retries if body is a stream for ANY method ([780c0f8](https://github.com/zkat/make-fetch-happen/commit/780c0f8)) | ||
* **cache:** default on cache-control header ([b872a2c](https://github.com/npm/make-fetch-happen/commit/b872a2c)) | ||
* standard stuff and cache matching ([753f2c2](https://github.com/npm/make-fetch-happen/commit/753f2c2)) | ||
* **agent:** nudge around things with opts.agent ([ed62b57](https://github.com/npm/make-fetch-happen/commit/ed62b57)) | ||
* **agent:** {agent: false} has special behavior ([b8cc923](https://github.com/npm/make-fetch-happen/commit/b8cc923)) | ||
* **cache:** invalidation on non-GET ([fe78fac](https://github.com/npm/make-fetch-happen/commit/fe78fac)) | ||
* **cache:** make force-cache and only-if-cached work as expected ([f50e9df](https://github.com/npm/make-fetch-happen/commit/f50e9df)) | ||
* **cache:** more spec compliance ([d5a56db](https://github.com/npm/make-fetch-happen/commit/d5a56db)) | ||
* **cache:** only cache 200 gets ([0abb25a](https://github.com/npm/make-fetch-happen/commit/0abb25a)) | ||
* **cache:** only load cache code if cache opt is a string ([250fcd5](https://github.com/npm/make-fetch-happen/commit/250fcd5)) | ||
* **cache:** oops ([e3fa15a](https://github.com/npm/make-fetch-happen/commit/e3fa15a)) | ||
* **cache:** refactored warning removal into main file ([5b0a9f9](https://github.com/npm/make-fetch-happen/commit/5b0a9f9)) | ||
* **cache:** req constructor no longer needed in Cache ([5b74cbc](https://github.com/npm/make-fetch-happen/commit/5b74cbc)) | ||
* **cache:** standard fetch api calls cacheMode "cache" ([6fba805](https://github.com/npm/make-fetch-happen/commit/6fba805)) | ||
* **cache:** was using wrong method for non-GET/HEAD cache invalidation ([810763a](https://github.com/npm/make-fetch-happen/commit/810763a)) | ||
* **caching:** a bunch of cache-related fixes ([8ebda1d](https://github.com/npm/make-fetch-happen/commit/8ebda1d)) | ||
* **deps:** `cacache[@6](https://github.com/6).3.0` - race condition fixes ([9528442](https://github.com/npm/make-fetch-happen/commit/9528442)) | ||
* **freshness:** fix regex for cacheControl matching ([070db86](https://github.com/npm/make-fetch-happen/commit/070db86)) | ||
* **freshness:** fixed default freshness heuristic value ([5d29e88](https://github.com/npm/make-fetch-happen/commit/5d29e88)) | ||
* **logging:** remove console.log calls ([a1d0a47](https://github.com/npm/make-fetch-happen/commit/a1d0a47)) | ||
* **method:** node-fetch guarantees uppercase ([a1d68d6](https://github.com/npm/make-fetch-happen/commit/a1d68d6)) | ||
* **opts:** simplified opts handling ([516fd6e](https://github.com/npm/make-fetch-happen/commit/516fd6e)) | ||
* **proxy:** pass proxy option directly to ProxyAgent ([3398460](https://github.com/npm/make-fetch-happen/commit/3398460)) | ||
* **retry:** false -> {retries: 0} ([297fbb6](https://github.com/npm/make-fetch-happen/commit/297fbb6)) | ||
* **retry:** only retry put if body is not a stream ([a24e599](https://github.com/npm/make-fetch-happen/commit/a24e599)) | ||
* **retry:** skip retries if body is a stream for ANY method ([780c0f8](https://github.com/npm/make-fetch-happen/commit/780c0f8)) | ||
@@ -661,4 +678,4 @@ | ||
* **api:** initial implementation -- can make and cache requests ([7d55b49](https://github.com/zkat/make-fetch-happen/commit/7d55b49)) | ||
* **fetch:** injectable cache, and retry support ([87b84bf](https://github.com/zkat/make-fetch-happen/commit/87b84bf)) | ||
* **api:** initial implementation -- can make and cache requests ([7d55b49](https://github.com/npm/make-fetch-happen/commit/7d55b49)) | ||
* **fetch:** injectable cache, and retry support ([87b84bf](https://github.com/npm/make-fetch-happen/commit/87b84bf)) | ||
@@ -665,0 +682,0 @@ |
66
index.js
@@ -6,7 +6,8 @@ 'use strict' | ||
const CachePolicy = require('http-cache-semantics') | ||
const fetch = require('node-fetch-npm') | ||
const fetch = require('minipass-fetch') | ||
const pkg = require('./package.json') | ||
const retry = require('promise-retry') | ||
let ssri | ||
const Stream = require('stream') | ||
const Minipass = require('minipass') | ||
const getAgent = require('./agent') | ||
@@ -112,3 +113,3 @@ const setWarning = require('./warning') | ||
initializeSsri() | ||
// if verifying integrity, node-fetch must not decompress | ||
// if verifying integrity, fetch must not decompress | ||
opts.compress = false | ||
@@ -177,3 +178,2 @@ } | ||
} | ||
return remoteFetch(uri, opts) | ||
@@ -225,2 +225,10 @@ } | ||
const bool = !policy.satisfiesWithoutRevalidation(_req) | ||
const headers = policy.responseHeaders() | ||
if (headers.warning && /^113\b/.test(headers.warning)) { | ||
// Possible to pick up a rfc7234 warning at this point. | ||
// This is kind of a weird place to stick this, should probably go | ||
// in cachingFetch. But by putting it here, we save an extra | ||
// CachePolicy object construction. | ||
res.headers.append('warning', headers.warning) | ||
} | ||
return bool | ||
@@ -261,6 +269,18 @@ } | ||
if (condRes.status === 304) { // 304 Not Modified | ||
condRes.body = cachedRes.body | ||
return opts.cacheManager.put(req, condRes, opts) | ||
// Create a synthetic response from the cached body and original req | ||
const synthRes = new fetch.Response(cachedRes.body, condRes) | ||
return opts.cacheManager.put(req, synthRes, opts) | ||
.then(newRes => { | ||
newRes.headers = new fetch.Headers(revalidatedPolicy.policy.responseHeaders()) | ||
// Get the list first, because if we delete while iterating, | ||
// it'll throw off the count and not make it through all | ||
// of them. | ||
const newHeaders = revalidatedPolicy.policy.responseHeaders() | ||
const toDelete = [...newRes.headers.keys()] | ||
.filter(k => !newHeaders[k]) | ||
for (const key of toDelete) { | ||
newRes.headers.delete(key) | ||
} | ||
for (const [key, val] of Object.entries(newHeaders)) { | ||
newRes.headers.set(key, val) | ||
} | ||
return newRes | ||
@@ -305,9 +325,5 @@ }) | ||
oldBod.pipe(newBod) | ||
res.body = newBod | ||
oldBod.once('error', err => { | ||
newBod.emit('error', err) | ||
}) | ||
newBod.once('error', err => { | ||
oldBod.emit('error', err) | ||
}) | ||
oldBod.on('error', er => newBod.emit('error')) | ||
return new fetch.Response(newBod, res) | ||
} | ||
@@ -340,10 +356,10 @@ | ||
.then(res => { | ||
res.headers.set('x-fetch-attempts', attemptNum) | ||
if (opts.integrity) { | ||
remoteFetchHandleIntegrity(res, opts.integrity) | ||
res = remoteFetchHandleIntegrity(res, opts.integrity) | ||
} | ||
const isStream = req.body instanceof Stream | ||
res.headers.set('x-fetch-attempts', attemptNum) | ||
const isStream = Minipass.isStream(req.body) | ||
if (opts.cacheManager) { | ||
@@ -397,6 +413,5 @@ const isMethodGetHead = req.method === 'GET' || | ||
// handle redirects - matches behavior of npm-fetch: https://github.com/bitinn/node-fetch | ||
// handle redirects - matches behavior of fetch: https://github.com/bitinn/node-fetch | ||
if (opts.redirect === 'error') { | ||
const err = new Error(`redirect mode is set to error: ${uri}`) | ||
err.code = 'ENOREDIRECT' | ||
const err = new fetch.FetchError(`redirect mode is set to error: ${uri}`, 'no-redirect', { code: 'ENOREDIRECT' }) | ||
throw err | ||
@@ -406,4 +421,3 @@ } | ||
if (!res.headers.get('location')) { | ||
const err = new Error(`redirect location header missing at: ${uri}`) | ||
err.code = 'EINVALIDREDIRECT' | ||
const err = new fetch.FetchError(`redirect location header missing at: ${uri}`, 'no-location', { code: 'EINVALIDREDIRECT' }) | ||
throw err | ||
@@ -413,4 +427,3 @@ } | ||
if (req.counter >= req.follow) { | ||
const err = new Error(`maximum redirect reached at: ${uri}`) | ||
err.code = 'EMAXREDIRECT' | ||
const err = new fetch.FetchError(`maximum redirect reached at: ${uri}`, 'max-redirect', { code: 'EMAXREDIRECT' }) | ||
throw err | ||
@@ -469,3 +482,4 @@ } | ||
).catch(err => { | ||
if (err.status >= 400) { | ||
if (err.status >= 400 && err.type !== 'system') { | ||
// this is an HTTP response "error" that we care about | ||
return err | ||
@@ -472,0 +486,0 @@ } |
{ | ||
"name": "make-fetch-happen", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"description": "Opinionated, caching, retrying fetch client", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
}, | ||
"repository": "https://github.com/zkat/make-fetch-happen", | ||
"repository": "https://github.com/npm/make-fetch-happen", | ||
"keywords": [ | ||
@@ -38,3 +38,3 @@ "http", | ||
"agentkeepalive": "^3.4.1", | ||
"cacache": "^12.0.0", | ||
"cacache": "^13.0.1", | ||
"http-cache-semantics": "^3.8.1", | ||
@@ -44,10 +44,12 @@ "http-proxy-agent": "^2.1.0", | ||
"lru-cache": "^5.1.1", | ||
"mississippi": "^3.0.0", | ||
"node-fetch-npm": "^2.0.2", | ||
"minipass": "^3.0.0", | ||
"minipass-collect": "^1.0.2", | ||
"minipass-fetch": "^1.1.2", | ||
"minipass-flush": "^1.0.5", | ||
"minipass-pipeline": "^1.2.2", | ||
"promise-retry": "^1.1.1", | ||
"socks-proxy-agent": "^4.0.0", | ||
"ssri": "^6.0.0" | ||
"ssri": "^7.0.1" | ||
}, | ||
"devDependencies": { | ||
"bluebird": "^3.5.1", | ||
"mkdirp": "^0.5.1", | ||
@@ -62,6 +64,9 @@ "nock": "^9.2.3", | ||
"tacks": "^1.2.6", | ||
"tap": "^12.7.0", | ||
"tap": "^14.6.9", | ||
"weallbehave": "^1.0.0", | ||
"weallcontribute": "^1.0.7" | ||
}, | ||
"engines": { | ||
"node": ">= 8" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
66172
12
14
800
24
+ Addedminipass@^3.0.0
+ Addedminipass-collect@^1.0.2
+ Addedminipass-fetch@^1.1.2
+ Addedminipass-flush@^1.0.5
+ Addedminipass-pipeline@^1.2.2
+ Addedaggregate-error@3.1.0(transitive)
+ Addedcacache@13.0.1(transitive)
+ Addedclean-stack@2.2.0(transitive)
+ Addedfs-minipass@2.1.0(transitive)
+ Addedindent-string@4.0.0(transitive)
+ Addedminipass@3.3.6(transitive)
+ Addedminipass-collect@1.0.2(transitive)
+ Addedminipass-fetch@1.4.1(transitive)
+ Addedminipass-flush@1.0.5(transitive)
+ Addedminipass-pipeline@1.2.4(transitive)
+ Addedminipass-sized@1.0.3(transitive)
+ Addedminizlib@2.1.2(transitive)
+ Addedp-map@3.0.0(transitive)
+ Addedssri@7.1.1(transitive)
+ Addedyallist@4.0.0(transitive)
- Removedmississippi@^3.0.0
- Removednode-fetch-npm@^2.0.2
- Removedbluebird@3.7.2(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedcacache@12.0.4(transitive)
- Removedconcat-stream@1.6.2(transitive)
- Removedcyclist@1.0.2(transitive)
- Removedduplexify@3.7.1(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedflush-write-stream@1.1.1(transitive)
- Removedfrom2@2.3.0(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedmississippi@3.0.0(transitive)
- Removednode-fetch-npm@2.0.4(transitive)
- Removedparallel-transform@1.2.0(transitive)
- Removedpump@2.0.13.0.2(transitive)
- Removedpumpify@1.5.1(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedssri@6.0.2(transitive)
- Removedstream-each@1.2.3(transitive)
- Removedstream-shift@1.0.3(transitive)
- Removedthrough2@2.0.5(transitive)
- Removedtypedarray@0.0.6(transitive)
- Removedxtend@4.0.2(transitive)
- Removedy18n@4.0.3(transitive)
Updatedcacache@^13.0.1
Updatedssri@^7.0.1