static-server
Advanced tools
Comparing version 2.0.6 to 2.1.0
@@ -9,2 +9,3 @@ #!/usr/bin/env node | ||
const DEFAULT_CORS = undefined; | ||
const DEFAULT_CACHE = true; | ||
@@ -35,2 +36,3 @@ | ||
.option('-c, --cors <pattern>', 'Cross Origin Pattern. Use "*" to allow all origins', DEFAULT_CORS) | ||
.option('-z, --no-cache', 'disable cache (http 304) responses', DEFAULT_CACHE) | ||
.parse(process.argv); | ||
@@ -37,0 +39,0 @@ ; |
{ | ||
"name": "static-server", | ||
"description": "A simple http server to serve static resource files from a local directory.", | ||
"version": "2.0.6", | ||
"version": "2.1.0", | ||
"author": "Eduardo Bohrer <nbluisrs@gmail.com>", | ||
@@ -15,3 +15,3 @@ "keywords": [ | ||
"type": "git", | ||
"url": "git@github.com:nbluis/static-server.git" | ||
"url": "https://github.com:nbluis/static-server.git" | ||
}, | ||
@@ -35,9 +35,6 @@ "bin": { | ||
}, | ||
"license": { | ||
"type": "MIT", | ||
"url": "http://creativecommons.org/licenses/MIT/" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"istanbul": "^0.3.0", | ||
"mocha": "^1.21.4", | ||
"mocha": "^4.0.1", | ||
"should": "^4.0.4", | ||
@@ -44,0 +41,0 @@ "supertest": "^0.15.0" |
@@ -22,2 +22,3 @@ [![Build Status](https://secure.travis-ci.org/nbluis/static-server.svg?branch=master)](http://travis-ci.org/nbluis/static-server) | ||
-c, --cors <pattern> Cross Origin Pattern. Use "*" to allow all origins | ||
-z, --no-nocache disable cache (http 304) responses. | ||
@@ -24,0 +25,0 @@ ## Using as a node module |
@@ -56,2 +56,3 @@ | ||
- notFound the 404 error template | ||
- noCache disables 304 responses | ||
@@ -81,2 +82,4 @@ @param options {Object} | ||
}; | ||
// the arguments parser converts `--no-XXXX` to `XXXX` with a value of false; | ||
this.noCache = !options.cache; | ||
@@ -298,2 +301,4 @@ if (options.index) { | ||
if (server.noCache) return false; | ||
if ((clientMTime || clientETag) && | ||
@@ -458,5 +463,8 @@ (!clientETag || clientETag === res.headers['Etag']) && | ||
res.headers['Etag'] = JSON.stringify([stat.ino, stat.size, stat.mtime.getTime()].join('-')); | ||
if (!server.noCache) { | ||
res.headers['Etag'] = JSON.stringify([stat.ino, stat.size, stat.mtime.getTime()].join('-')); | ||
res.headers['Last-Modified'] = new Date(stat.mtime).toUTCString(); | ||
} | ||
res.headers['Date'] = new Date().toUTCString(); | ||
res.headers['Last-Modified'] = new Date(stat.mtime).toUTCString(); | ||
@@ -463,0 +471,0 @@ if (contentParts.ranges && contentParts.ranges.length > 1) { |
Sorry, the diff of this file is not supported yet
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
29095
665
81