aboutsummaryrefslogtreecommitdiffhomepage
path: root/node_modules/fresh
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/fresh')
-rw-r--r--node_modules/fresh/HISTORY.md70
-rw-r--r--node_modules/fresh/LICENSE23
-rw-r--r--node_modules/fresh/README.md119
-rw-r--r--node_modules/fresh/index.js137
-rw-r--r--node_modules/fresh/package.json126
5 files changed, 475 insertions, 0 deletions
diff --git a/node_modules/fresh/HISTORY.md b/node_modules/fresh/HISTORY.md
new file mode 100644
index 0000000..4586996
--- /dev/null
+++ b/node_modules/fresh/HISTORY.md
@@ -0,0 +1,70 @@
+0.5.2 / 2017-09-13
+==================
+
+ * Fix regression matching multiple ETags in `If-None-Match`
+ * perf: improve `If-None-Match` token parsing
+
+0.5.1 / 2017-09-11
+==================
+
+ * Fix handling of modified headers with invalid dates
+ * perf: improve ETag match loop
+
+0.5.0 / 2017-02-21
+==================
+
+ * Fix incorrect result when `If-None-Match` has both `*` and ETags
+ * Fix weak `ETag` matching to match spec
+ * perf: delay reading header values until needed
+ * perf: skip checking modified time if ETag check failed
+ * perf: skip parsing `If-None-Match` when no `ETag` header
+ * perf: use `Date.parse` instead of `new Date`
+
+0.4.0 / 2017-02-05
+==================
+
+ * Fix false detection of `no-cache` request directive
+ * perf: enable strict mode
+ * perf: hoist regular expressions
+ * perf: remove duplicate conditional
+ * perf: remove unnecessary boolean coercions
+
+0.3.0 / 2015-05-12
+==================
+
+ * Add weak `ETag` matching support
+
+0.2.4 / 2014-09-07
+==================
+
+ * Support Node.js 0.6
+
+0.2.3 / 2014-09-07
+==================
+
+ * Move repository to jshttp
+
+0.2.2 / 2014-02-19
+==================
+
+ * Revert "Fix for blank page on Safari reload"
+
+0.2.1 / 2014-01-29
+==================
+
+ * Fix for blank page on Safari reload
+
+0.2.0 / 2013-08-11
+==================
+
+ * Return stale for `Cache-Control: no-cache`
+
+0.1.0 / 2012-06-15
+==================
+
+ * Add `If-None-Match: *` support
+
+0.0.1 / 2012-06-10
+==================
+
+ * Initial release
diff --git a/node_modules/fresh/LICENSE b/node_modules/fresh/LICENSE
new file mode 100644
index 0000000..1434ade
--- /dev/null
+++ b/node_modules/fresh/LICENSE
@@ -0,0 +1,23 @@
+(The MIT License)
+
+Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
+Copyright (c) 2016-2017 Douglas Christopher Wilson <doug@somethingdoug.com>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/fresh/README.md b/node_modules/fresh/README.md
new file mode 100644
index 0000000..1c1c680
--- /dev/null
+++ b/node_modules/fresh/README.md
@@ -0,0 +1,119 @@
+# fresh
+
+[![NPM Version][npm-image]][npm-url]
+[![NPM Downloads][downloads-image]][downloads-url]
+[![Node.js Version][node-version-image]][node-version-url]
+[![Build Status][travis-image]][travis-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
+
+HTTP response freshness testing
+
+## Installation
+
+This is a [Node.js](https://nodejs.org/en/) module available through the
+[npm registry](https://www.npmjs.com/). Installation is done using the
+[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
+
+```
+$ npm install fresh
+```
+
+## API
+
+<!-- eslint-disable no-unused-vars -->
+
+```js
+var fresh = require('fresh')
+```
+
+### fresh(reqHeaders, resHeaders)
+
+Check freshness of the response using request and response headers.
+
+When the response is still "fresh" in the client's cache `true` is
+returned, otherwise `false` is returned to indicate that the client
+cache is now stale and the full response should be sent.
+
+When a client sends the `Cache-Control: no-cache` request header to
+indicate an end-to-end reload request, this module will return `false`
+to make handling these requests transparent.
+
+## Known Issues
+
+This module is designed to only follow the HTTP specifications, not
+to work-around all kinda of client bugs (especially since this module
+typically does not recieve enough information to understand what the
+client actually is).
+
+There is a known issue that in certain versions of Safari, Safari
+will incorrectly make a request that allows this module to validate
+freshness of the resource even when Safari does not have a
+representation of the resource in the cache. The module
+[jumanji](https://www.npmjs.com/package/jumanji) can be used in
+an Express application to work-around this issue and also provides
+links to further reading on this Safari bug.
+
+## Example
+
+### API usage
+
+<!-- eslint-disable no-redeclare, no-undef -->
+
+```js
+var reqHeaders = { 'if-none-match': '"foo"' }
+var resHeaders = { 'etag': '"bar"' }
+fresh(reqHeaders, resHeaders)
+// => false
+
+var reqHeaders = { 'if-none-match': '"foo"' }
+var resHeaders = { 'etag': '"foo"' }
+fresh(reqHeaders, resHeaders)
+// => true
+```
+
+### Using with Node.js http server
+
+```js
+var fresh = require('fresh')
+var http = require('http')
+
+var server = http.createServer(function (req, res) {
+ // perform server logic
+ // ... including adding ETag / Last-Modified response headers
+
+ if (isFresh(req, res)) {
+ // client has a fresh copy of resource
+ res.statusCode = 304
+ res.end()
+ return
+ }
+
+ // send the resource
+ res.statusCode = 200
+ res.end('hello, world!')
+})
+
+function isFresh (req, res) {
+ return fresh(req.headers, {
+ 'etag': res.getHeader('ETag'),
+ 'last-modified': res.getHeader('Last-Modified')
+ })
+}
+
+server.listen(3000)
+```
+
+## License
+
+[MIT](LICENSE)
+
+[npm-image]: https://img.shields.io/npm/v/fresh.svg
+[npm-url]: https://npmjs.org/package/fresh
+[node-version-image]: https://img.shields.io/node/v/fresh.svg
+[node-version-url]: https://nodejs.org/en/
+[travis-image]: https://img.shields.io/travis/jshttp/fresh/master.svg
+[travis-url]: https://travis-ci.org/jshttp/fresh
+[coveralls-image]: https://img.shields.io/coveralls/jshttp/fresh/master.svg
+[coveralls-url]: https://coveralls.io/r/jshttp/fresh?branch=master
+[downloads-image]: https://img.shields.io/npm/dm/fresh.svg
+[downloads-url]: https://npmjs.org/package/fresh
diff --git a/node_modules/fresh/index.js b/node_modules/fresh/index.js
new file mode 100644
index 0000000..d154f5a
--- /dev/null
+++ b/node_modules/fresh/index.js
@@ -0,0 +1,137 @@
+/*!
+ * fresh
+ * Copyright(c) 2012 TJ Holowaychuk
+ * Copyright(c) 2016-2017 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * RegExp to check for no-cache token in Cache-Control.
+ * @private
+ */
+
+var CACHE_CONTROL_NO_CACHE_REGEXP = /(?:^|,)\s*?no-cache\s*?(?:,|$)/
+
+/**
+ * Module exports.
+ * @public
+ */
+
+module.exports = fresh
+
+/**
+ * Check freshness of the response using request and response headers.
+ *
+ * @param {Object} reqHeaders
+ * @param {Object} resHeaders
+ * @return {Boolean}
+ * @public
+ */
+
+function fresh (reqHeaders, resHeaders) {
+ // fields
+ var modifiedSince = reqHeaders['if-modified-since']
+ var noneMatch = reqHeaders['if-none-match']
+
+ // unconditional request
+ if (!modifiedSince && !noneMatch) {
+ return false
+ }
+
+ // Always return stale when Cache-Control: no-cache
+ // to support end-to-end reload requests
+ // https://tools.ietf.org/html/rfc2616#section-14.9.4
+ var cacheControl = reqHeaders['cache-control']
+ if (cacheControl && CACHE_CONTROL_NO_CACHE_REGEXP.test(cacheControl)) {
+ return false
+ }
+
+ // if-none-match
+ if (noneMatch && noneMatch !== '*') {
+ var etag = resHeaders['etag']
+
+ if (!etag) {
+ return false
+ }
+
+ var etagStale = true
+ var matches = parseTokenList(noneMatch)
+ for (var i = 0; i < matches.length; i++) {
+ var match = matches[i]
+ if (match === etag || match === 'W/' + etag || 'W/' + match === etag) {
+ etagStale = false
+ break
+ }
+ }
+
+ if (etagStale) {
+ return false
+ }
+ }
+
+ // if-modified-since
+ if (modifiedSince) {
+ var lastModified = resHeaders['last-modified']
+ var modifiedStale = !lastModified || !(parseHttpDate(lastModified) <= parseHttpDate(modifiedSince))
+
+ if (modifiedStale) {
+ return false
+ }
+ }
+
+ return true
+}
+
+/**
+ * Parse an HTTP Date into a number.
+ *
+ * @param {string} date
+ * @private
+ */
+
+function parseHttpDate (date) {
+ var timestamp = date && Date.parse(date)
+
+ // istanbul ignore next: guard against date.js Date.parse patching
+ return typeof timestamp === 'number'
+ ? timestamp
+ : NaN
+}
+
+/**
+ * Parse a HTTP token list.
+ *
+ * @param {string} str
+ * @private
+ */
+
+function parseTokenList (str) {
+ var end = 0
+ var list = []
+ var start = 0
+
+ // gather tokens
+ for (var i = 0, len = str.length; i < len; i++) {
+ switch (str.charCodeAt(i)) {
+ case 0x20: /* */
+ if (start === end) {
+ start = end = i + 1
+ }
+ break
+ case 0x2c: /* , */
+ list.push(str.substring(start, end))
+ start = end = i + 1
+ break
+ default:
+ end = i + 1
+ break
+ }
+ }
+
+ // final token
+ list.push(str.substring(start, end))
+
+ return list
+}
diff --git a/node_modules/fresh/package.json b/node_modules/fresh/package.json
new file mode 100644
index 0000000..750d001
--- /dev/null
+++ b/node_modules/fresh/package.json
@@ -0,0 +1,126 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "fresh@0.5.2",
+ "scope": null,
+ "escapedName": "fresh",
+ "name": "fresh",
+ "rawSpec": "0.5.2",
+ "spec": "0.5.2",
+ "type": "version"
+ },
+ "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/express"
+ ]
+ ],
+ "_from": "fresh@0.5.2",
+ "_id": "fresh@0.5.2",
+ "_inCache": true,
+ "_location": "/fresh",
+ "_nodeVersion": "6.11.1",
+ "_npmOperationalInternal": {
+ "host": "s3://npm-registry-packages",
+ "tmp": "tmp/fresh-0.5.2.tgz_1505365391149_0.7952043106779456"
+ },
+ "_npmUser": {
+ "name": "dougwilson",
+ "email": "doug@somethingdoug.com"
+ },
+ "_npmVersion": "3.10.10",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "fresh@0.5.2",
+ "scope": null,
+ "escapedName": "fresh",
+ "name": "fresh",
+ "rawSpec": "0.5.2",
+ "spec": "0.5.2",
+ "type": "version"
+ },
+ "_requiredBy": [
+ "/express",
+ "/send"
+ ],
+ "_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
+ "_shasum": "3d8cadd90d976569fa835ab1f8e4b23a105605a7",
+ "_shrinkwrap": null,
+ "_spec": "fresh@0.5.2",
+ "_where": "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/express",
+ "author": {
+ "name": "TJ Holowaychuk",
+ "email": "tj@vision-media.ca",
+ "url": "http://tjholowaychuk.com"
+ },
+ "bugs": {
+ "url": "https://github.com/jshttp/fresh/issues"
+ },
+ "contributors": [
+ {
+ "name": "Douglas Christopher Wilson",
+ "email": "doug@somethingdoug.com"
+ },
+ {
+ "name": "Jonathan Ong",
+ "email": "me@jongleberry.com",
+ "url": "http://jongleberry.com"
+ }
+ ],
+ "dependencies": {},
+ "description": "HTTP response freshness testing",
+ "devDependencies": {
+ "beautify-benchmark": "0.2.4",
+ "benchmark": "2.1.4",
+ "eslint": "3.19.0",
+ "eslint-config-standard": "10.2.1",
+ "eslint-plugin-import": "2.7.0",
+ "eslint-plugin-markdown": "1.0.0-beta.6",
+ "eslint-plugin-node": "5.1.1",
+ "eslint-plugin-promise": "3.5.0",
+ "eslint-plugin-standard": "3.0.1",
+ "istanbul": "0.4.5",
+ "mocha": "1.21.5"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "3d8cadd90d976569fa835ab1f8e4b23a105605a7",
+ "tarball": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ },
+ "files": [
+ "HISTORY.md",
+ "LICENSE",
+ "index.js"
+ ],
+ "gitHead": "02df6303ff260b6b7da0b479f3e42222e8157b47",
+ "homepage": "https://github.com/jshttp/fresh#readme",
+ "keywords": [
+ "fresh",
+ "http",
+ "conditional",
+ "cache"
+ ],
+ "license": "MIT",
+ "maintainers": [
+ {
+ "name": "dougwilson",
+ "email": "doug@somethingdoug.com"
+ }
+ ],
+ "name": "fresh",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/jshttp/fresh.git"
+ },
+ "scripts": {
+ "bench": "node benchmark/index.js",
+ "lint": "eslint --plugin markdown --ext js,md .",
+ "test": "mocha --reporter spec --bail --check-leaks test/",
+ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
+ "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
+ },
+ "version": "0.5.2"
+}