Socket
Socket
Sign inDemoInstall

make-fetch-happen

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-fetch-happen - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

24

cache.js

@@ -43,3 +43,3 @@ 'use strict'

return cacache.get.info(this._path, cacheKey(req)).then(info => {
if (info && matchDetails(req, {
if (info && info.metadata && matchDetails(req, {
url: info.metadata.url,

@@ -51,6 +51,9 @@ reqHeaders: new fetch.Headers(info.metadata.reqHeaders),

})) {
const resHeaders = new fetch.Headers(info.metadata.resHeaders)
resHeaders.set('X-LOCAL-CACHE', this._path)
resHeaders.set('X-LOCAL-CACHE-TIME', new Date(info.time).toUTCString())
if (req.method === 'HEAD') {
return new fetch.Response(null, {
url: req.url,
headers: info.metadata.resHeaders,
headers: resHeaders,
status: 200

@@ -99,3 +102,3 @@ })

url: req.url,
headers: info.metadata.resHeaders,
headers: resHeaders,
status: 200,

@@ -112,6 +115,7 @@ size: stat.size

// Takes both a request and its response and adds it to the given cache.
put (req, response) {
put (req, response, opts) {
const size = response.headers.get('content-length')
const fitInMemory = !!size && size < MAX_MEM_SIZE
const opts = {
const cacheOpts = {
algorithms: opts.algorithms,
metadata: {

@@ -131,7 +135,7 @@ url: req.url,

// Providing these will bypass content write
opts.integrity = info.integrity
cacheOpts.integrity = info.integrity
return new this.Promise((resolve, reject) => {
pipe(
cacache.get.stream.byDigest(this._path, info.integrity, opts),
cacache.put.stream(this._path, cacheKey(req), opts),
cacache.get.stream.byDigest(this._path, info.integrity, cacheOpts),
cacache.put.stream(this._path, cacheKey(req), cacheOpts),
err => err ? reject(err) : resolve(response)

@@ -159,3 +163,3 @@ )

Buffer.concat(buf, bufSize),
opts
cacheOpts
).then(

@@ -168,3 +172,3 @@ () => done(),

cacheTargetStream =
cacache.put.stream(cachePath, cacheKey(req), opts)
cacache.put.stream(cachePath, cacheKey(req), cacheOpts)
}

@@ -171,0 +175,0 @@ }

@@ -5,2 +5,18 @@ # Change Log

<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)
### Bug Fixes
* **cache:** if metadata is missing for some odd reason, ignore the entry ([a021a6b](https://github.com/zkat/make-fetch-happen/commit/a021a6b))
### Features
* **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))
<a name="1.2.1"></a>

@@ -7,0 +23,0 @@ ## [1.2.1](https://github.com/zkat/make-fetch-happen/compare/v1.2.0...v1.2.1) (2017-04-03)

@@ -268,3 +268,3 @@ 'use strict'

) {
return opts.cacheManager.put(req, res, opts.cacheOpts)
return opts.cacheManager.put(req, res, opts)
} else if (opts.cacheManager && (

@@ -271,0 +271,0 @@ (req.method !== 'GET' && req.method !== 'HEAD')

{
"name": "make-fetch-happen",
"version": "1.2.1",
"version": "1.3.0",
"description": "Opinionated, caching, retrying fetch client",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc