aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics')
-rw-r--r--deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js16
-rw-r--r--deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/node4/index.js22
-rw-r--r--deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/package.json18
-rw-r--r--deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/responsetest.js6
-rw-r--r--deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/revalidatetest.js15
5 files changed, 64 insertions, 13 deletions
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js
index 2e9c58c99f..8a5bcab597 100644
--- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js
+++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js
@@ -221,7 +221,14 @@ module.exports = class CachePolicy {
responseHeaders() {
const headers = this._copyWithoutHopByHopHeaders(this._resHeaders);
- headers.age = `${Math.round(this.age())}`;
+ const age = this.age();
+
+ // A cache SHOULD generate 113 warning if it heuristically chose a freshness
+ // lifetime greater than 24 hours and the response's age is greater than 24 hours.
+ if (age > 3600*24 && !this._hasExplicitExpiration() && this.maxAge() > 3600*24) {
+ headers.warning = (headers.warning ? `${headers.warning}, ` : '') + '113 - "rfc7234 5.5.4"';
+ }
+ headers.age = `${Math.round(age)}`;
return headers;
}
@@ -260,6 +267,13 @@ module.exports = class CachePolicy {
return isFinite(ageValue) ? ageValue : 0;
}
+ /**
+ * Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`.
+ *
+ * For an up-to-date value, see `timeToLive()`.
+ *
+ * @return Number
+ */
maxAge() {
if (!this.storable() || this._rescc['no-cache']) {
return 0;
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/node4/index.js b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/node4/index.js
index 7011106818..bcdaebe80f 100644
--- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/node4/index.js
+++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/node4/index.js
@@ -271,7 +271,14 @@ module.exports = function () {
CachePolicy.prototype.responseHeaders = function responseHeaders() {
var headers = this._copyWithoutHopByHopHeaders(this._resHeaders);
- headers.age = '' + Math.round(this.age());
+ var age = this.age();
+
+ // A cache SHOULD generate 113 warning if it heuristically chose a freshness
+ // lifetime greater than 24 hours and the response's age is greater than 24 hours.
+ if (age > 3600 * 24 && !this._hasExplicitExpiration() && this.maxAge() > 3600 * 24) {
+ headers.warning = (headers.warning ? `${headers.warning}, ` : '') + '113 - "rfc7234 5.5.4"';
+ }
+ headers.age = `${Math.round(age)}`;
return headers;
};
@@ -314,6 +321,15 @@ module.exports = function () {
return isFinite(ageValue) ? ageValue : 0;
};
+ /**
+ * Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`.
+ *
+ * For an up-to-date value, see `timeToLive()`.
+ *
+ * @return Number
+ */
+
+
CachePolicy.prototype.maxAge = function maxAge() {
if (!this.storable() || this._rescc['no-cache']) {
return 0;
@@ -442,7 +458,7 @@ module.exports = function () {
/* MUST send that entity-tag in any cache validation request (using If-Match or If-None-Match) if an entity-tag has been provided by the origin server. */
if (this._resHeaders.etag) {
- headers['if-none-match'] = headers['if-none-match'] ? headers['if-none-match'] + ', ' + this._resHeaders.etag : this._resHeaders.etag;
+ headers['if-none-match'] = headers['if-none-match'] ? `${headers['if-none-match']}, ${this._resHeaders.etag}` : this._resHeaders.etag;
}
// Clients MAY issue simple (non-subrange) GET requests with either weak validators or strong validators. Clients MUST NOT use weak validators in other forms of request.
@@ -531,7 +547,7 @@ module.exports = function () {
var newResponse = Object.assign({}, response, {
status: this._status,
method: this._method,
- headers: headers
+ headers
});
return {
policy: new this.constructor(request, newResponse),
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/package.json b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/package.json
index 0fde2994a3..0b18a6f9f6 100644
--- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/package.json
+++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/package.json
@@ -1,8 +1,8 @@
{
"_from": "http-cache-semantics@^3.7.3",
- "_id": "http-cache-semantics@3.7.3",
+ "_id": "http-cache-semantics@3.8.0",
"_inBundle": false,
- "_integrity": "sha1-LzXFMuzSnx5UE7mvgztySjxvf3I=",
+ "_integrity": "sha512-HGQFfBdru2fj/dwPn1oLx1fy6QMPeTAD1yzKcxD4l5biw+5QVaui/ehCqxaitoKJC/vHMLKv3Yd+nTlxboOJig==",
"_location": "/npm-profile/make-fetch-happen/http-cache-semantics",
"_phantomChildren": {},
"_requested": {
@@ -18,10 +18,10 @@
"_requiredBy": [
"/npm-profile/make-fetch-happen"
],
- "_resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.7.3.tgz",
- "_shasum": "2f35c532ecd29f1e5413b9af833b724a3c6f7f72",
+ "_resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.0.tgz",
+ "_shasum": "1e3ce248730e189ac692a6697b9e3fdea2ff8da3",
"_spec": "http-cache-semantics@^3.7.3",
- "_where": "/Users/rebecca/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen",
+ "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen",
"author": {
"name": "Kornel LesiƄski",
"email": "kornel@geekhood.net",
@@ -34,9 +34,9 @@
"deprecated": false,
"description": "Parses Cache-Control and other headers. Helps building correct HTTP caches and proxies",
"devDependencies": {
- "babel-cli": "^6.24.0",
- "babel-preset-env": "^1.3.2",
- "mocha": "^3.2.0"
+ "babel-cli": "^6.24.1",
+ "babel-preset-env": "^1.5.2",
+ "mocha": "^3.4.2"
},
"files": [
"node4/index.js",
@@ -56,5 +56,5 @@
"prepublish": "npm run compile",
"test": "npm run compile; mocha node4/test"
},
- "version": "3.7.3"
+ "version": "3.8.0"
}
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/responsetest.js b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/responsetest.js
index 27bdb28e04..763910b82c 100644
--- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/responsetest.js
+++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/responsetest.js
@@ -34,6 +34,12 @@ describe('Response headers', function() {
assert.equal(cache.maxAge(), 678);
});
+ it('IIS', function() {
+ const cache = new CachePolicy(req, {headers:{'cache-control': 'private, public, max-age=259200'}}, {shared:false});
+ assert(!cache.stale());
+ assert.equal(cache.maxAge(), 259200);
+ });
+
it('pre-check tolerated', function() {
const cc = 'pre-check=0, post-check=0, no-store, no-cache, max-age=100';
const cache = new CachePolicy(req, {headers:{'cache-control': cc}});
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/revalidatetest.js b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/revalidatetest.js
index 1f905ec27c..9dc737718d 100644
--- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/revalidatetest.js
+++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/test/revalidatetest.js
@@ -106,6 +106,7 @@ describe('Can be revalidated?', function() {
const headers = cache.revalidationHeaders(simpleRequest);
assertHeadersPassed(headers);
assert.equal(headers['if-modified-since'], 'Tue, 15 Nov 1994 12:45:26 GMT');
+ assert(!/113/.test(headers.warning));
});
it('not without validators', function() {
@@ -113,6 +114,20 @@ describe('Can be revalidated?', function() {
const headers = cache.revalidationHeaders(simpleRequest);
assertHeadersPassed(headers);
assertNoValidators(headers);
+ assert(!/113/.test(headers.warning));
+ })
+
+ it('113 added', function() {
+ const veryOldResponse = {
+ headers: {
+ age: 3600*72,
+ 'last-modified': 'Tue, 15 Nov 1994 12:45:26 GMT',
+ },
+ };
+
+ const cache = new CachePolicy(simpleRequest, veryOldResponse);
+ const headers = cache.responseHeaders(simpleRequest);
+ assert(/113/.test(headers.warning));
})
});