Comparing version 1.4.0 to 1.4.1
@@ -0,1 +1,4 @@ | ||
2015/05/10 Version 1.4.1 | ||
- Compare if-modified-since header against server-generated last-modified header rather than raw mtime | ||
2015/12/22 Version 1.4.0 | ||
@@ -2,0 +5,0 @@ - Add ability to specify custom mimetypes via a JSON blob (on the CLI) |
@@ -19,53 +19,2 @@ # Contributing Guidelines | ||
## Windows Users | ||
Before you clone ecstatic you unfortunately have to configure git to not pull | ||
certain files. | ||
The test suite has a | ||
[test](https://github.com/jfhbrook/node-ecstatic/blob/master/test/showdir-pathname-encoding.js#L28-L29) | ||
for proper HTML entities encoding which depends on a character which is | ||
[illegal in Windows](https://github.com/jfhbrook/node-ecstatic/issues/172). | ||
This breaks `git clone` in Windows. | ||
Until someone has an epiphany and thinks up of a character which is acceptable | ||
on multiple platforms and effectively tests this behavior, here's how to get | ||
around it: | ||
1) Create and initialize your new repository (`<url>` is your fork): | ||
```bash | ||
mkdir node-ecstatic | ||
cd node-ecstatic | ||
git init | ||
git remote add –f origin <url> | ||
``` | ||
2) Enable sparse-checkout: | ||
```bash | ||
git config core.sparsecheckout true | ||
``` | ||
3) Configure sparse-checkout by listing your desired and excluded sub-trees | ||
in .git/info/sparse-checkout (paste this into notepad): | ||
```winbatch | ||
/* | ||
!test/public/<dir> | ||
!test/showdir-search-encoding.js | ||
!test/showdir-pathname-encoding.js | ||
``` | ||
This configures git to pull everything but the offending directory and tests which depend on it being there. | ||
4) Checkout from the remote: | ||
```bash | ||
git pull origin master | ||
``` | ||
You can read all the details about sparse-checkout in the | ||
[git documentation](https://git-scm.com/docs/git-read-tree#_sparse_checkout). | ||
## Branching | ||
@@ -72,0 +21,0 @@ |
@@ -13,3 +13,3 @@ #! /usr/bin/env node | ||
status = require('./ecstatic/status-handlers'), | ||
etag = require('./ecstatic/etag'), | ||
generateEtag = require('./ecstatic/etag'), | ||
optsParser = require('./ecstatic/opts'); | ||
@@ -230,4 +230,6 @@ | ||
// TODO: Helper for this, with default headers. | ||
res.setHeader('etag', etag(stat, weakEtags)); | ||
res.setHeader('last-modified', (new Date(stat.mtime)).toUTCString()); | ||
var lastModified = (new Date(stat.mtime)).toUTCString(), | ||
etag = generateEtag(stat, weakEtags); | ||
res.setHeader('last-modified', lastModified); | ||
res.setHeader('etag', etag); | ||
@@ -245,3 +247,3 @@ if (typeof cache === 'function') { | ||
// Return a 304 if necessary | ||
if (shouldReturn304(req, stat)) { | ||
if (shouldReturn304(req, lastModified, etag)) { | ||
return status[304](res, next); | ||
@@ -270,5 +272,3 @@ } | ||
// Do a strong or weak etag comparison based on setting | ||
// https://www.ietf.org/rfc/rfc2616.txt Section 13.3.3 | ||
function shouldReturn304(req, stat) { | ||
function shouldReturn304(req, serverLastModified, serverEtag) { | ||
if (!req || !req.headers) { | ||
@@ -278,7 +278,6 @@ return false; | ||
var modifiedSince = req.headers['if-modified-since'], | ||
clientEtag = req.headers['if-none-match'], | ||
serverEtag = etag(stat, opts.weakEtags); | ||
var clientModifiedSince = req.headers['if-modified-since'], | ||
clientEtag = req.headers['if-none-match']; | ||
if (!modifiedSince && !clientEtag) { | ||
if (!clientModifiedSince && !clientEtag) { | ||
// Client did not provide any conditional caching headers | ||
@@ -288,15 +287,15 @@ return false; | ||
// Catch "illegal access" dates that will crash v8 | ||
// https://github.com/jfhbrook/node-ecstatic/pull/179 | ||
if (modifiedSince) { | ||
if (clientModifiedSince) { | ||
// Catch "illegal access" dates that will crash v8 | ||
// https://github.com/jfhbrook/node-ecstatic/pull/179 | ||
try { | ||
var modifiedDate = new Date(Date.parse(modifiedSince)); | ||
var clientModifiedDate = new Date(Date.parse(clientModifiedSince)); | ||
} | ||
catch (err) { return false } | ||
if (modifiedDate.toString() === 'Invalid Date') { | ||
if (clientModifiedDate.toString() === 'Invalid Date') { | ||
return false; | ||
} | ||
// If any of the headers provided don't match, then don't return 304 | ||
if (modifiedDate < stat.mtime) { | ||
// If the client's copy is older than the server's, don't return 304 | ||
if (clientModifiedDate < new Date(serverLastModified)) { | ||
return false; | ||
@@ -307,2 +306,4 @@ } | ||
if (clientEtag) { | ||
// Do a strong or weak etag comparison based on setting | ||
// https://www.ietf.org/rfc/rfc2616.txt Section 13.3.3 | ||
if (opts.weakCompare && clientEtag !== serverEtag | ||
@@ -309,0 +310,0 @@ && clientEtag !== ('W/' + serverEtag) && ('W/' + clientEtag) !== serverEtag) { |
@@ -157,3 +157,3 @@ var ecstatic = require('../ecstatic'), | ||
process.version + | ||
'/ <a href="https://github.com/jesusabdullah/node-ecstatic">ecstatic</a> ' + | ||
'/ <a href="https://github.com/jfhbrook/node-ecstatic">ecstatic</a> ' + | ||
'server running @ ' + | ||
@@ -160,0 +160,0 @@ he.encode(req.headers.host || '') + '</address>\n' + |
@@ -5,3 +5,3 @@ { | ||
"description": "A simple static file server middleware that works with both Express and Flatiron", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"homepage": "https://github.com/jfhbrook/node-ecstatic", | ||
@@ -29,3 +29,3 @@ "repository": { | ||
"minimist": "^1.1.0", | ||
"url-join": "0.0.1" | ||
"url-join": "^1.0.0" | ||
}, | ||
@@ -37,6 +37,5 @@ "devDependencies": { | ||
"request": "^2.49.0", | ||
"tap": "^2.3.1", | ||
"union": "^0.4.4" | ||
"tap": "^5.7.0" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -5,4 +5,4 @@ # Ecstatic [![build status](https://secure.travis-ci.org/jfhbrook/node-ecstatic.png)](http://travis-ci.org/jfhbrook/node-ecstatic) | ||
A simple static file server middleware. Use it with a raw http server, | ||
express/connect, or flatiron/union! | ||
A simple static file server middleware. Use it with a raw http server or | ||
express/connect! | ||
@@ -25,17 +25,2 @@ # Examples: | ||
## union | ||
``` js | ||
var union = require('union'); | ||
var ecstatic = require('ecstatic'); | ||
union.createServer({ | ||
before: [ | ||
ecstatic({ root: __dirname + '/public' }), | ||
] | ||
}).listen(8080); | ||
console.log('Listening on :8080'); | ||
``` | ||
## stock http server | ||
@@ -42,0 +27,0 @@ |
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
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
5
856
242301
221
+ Addedurl-join@1.1.0(transitive)
- Removedurl-join@0.0.1(transitive)
Updatedurl-join@^1.0.0