mirror of
https://github.com/sstent/node.git
synced 2026-01-26 15:12:37 +00:00
updated app
This commit is contained in:
13
first-project/node_modules/gzippo/.npmignore
generated
vendored
Normal file
13
first-project/node_modules/gzippo/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
node_modules/*
|
||||
.DS_STORE
|
||||
*.swp
|
||||
*.monitor
|
||||
nodemon-ignore
|
||||
.*.sw[a-z]
|
||||
*.un~i
|
||||
.DS_Store
|
||||
Icon?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
bench/*
|
||||
3
first-project/node_modules/gzippo/.travis.yml
generated
vendored
Normal file
3
first-project/node_modules/gzippo/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
70
first-project/node_modules/gzippo/README.md
generated
vendored
Normal file
70
first-project/node_modules/gzippo/README.md
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
# gzippo [](https://secure.travis-ci.org/tomgco/gzippo)
|
||||
|
||||
gzippo pronounced `g-zippo` is a gzip middleware for Connect / expressjs using node-compress for better performace, in node 0.6 and up will be using the new zlib api.
|
||||
|
||||
gzippo currently only supports only gzipping static content files however a release is in progress to introduce streaming support.
|
||||
|
||||
## Notice
|
||||
|
||||
Please note that gzippo@0.0.X branch will only be tested for nodejs 0.4, where the soon to be released gzippo@0.1.X will work for node 0.6
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install gzippo
|
||||
|
||||
### Usage
|
||||
#### Static Gzip
|
||||
|
||||
In your express/connect server setup, use as follows:
|
||||
|
||||
var gzippo = require('gzippo');
|
||||
|
||||
//Replace the static provider with gzippo's
|
||||
//app.use(express.static(__dirname + '/public'));
|
||||
app.use(gzippo.staticGzip(__dirname + '/public'));
|
||||
|
||||
Options:
|
||||
|
||||
- `contentTypeMatch` - A regular expression tested against the Content-Type header to determine whether the response should be gzipped or not. The default value is `/text|javascript|json/`.
|
||||
- `maxAge` - cache-control max-age directive, defaulting to 1 day
|
||||
- `clientMaxAge` - browser cache-control max-age directive, defaulting to 1 week
|
||||
- `prefix` - A url prefix. If you want all your static content in a root path such as /resource/. Any url paths not matching will be ignored
|
||||
|
||||
Currently the gzipped version is created and stored in memory. This is not final and was done to get a working version
|
||||
up and about.
|
||||
|
||||
Gzippo now uses the native Zlib support found in node >= 0.6
|
||||
|
||||
#### Streaming Gzip
|
||||
|
||||
Starting in Connect 2.X Expressjs has the ability to use a streaming gzip module provided natively by connect. As this 2.X branch is not currently stable I have back ported the compress.js component into gzippo.
|
||||
|
||||
app.use(gzippo.staticGzip(__dirname + '/public'));
|
||||
app.use(gzippo.compress());
|
||||
|
||||
This has no caching and is currently unsupported as it will be included in a future connect 1.X release, up until then compress.js will be included in gzippo.
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011 Tom Gallacher <<http://www.tomg.co>>
|
||||
|
||||
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.
|
||||
2
first-project/node_modules/gzippo/index.js
generated
vendored
Normal file
2
first-project/node_modules/gzippo/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
exports.staticGzip = require("./lib/staticGzip.js");
|
||||
exports.compress = require("./lib/compress.js");
|
||||
139
first-project/node_modules/gzippo/lib/compress.js
generated
vendored
Normal file
139
first-project/node_modules/gzippo/lib/compress.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
|
||||
/*!
|
||||
* Connect - compress
|
||||
* Copyright(c) 2010 Sencha Inc.
|
||||
* Copyright(c) 2011 TJ Holowaychuk
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var zlib = require('zlib');
|
||||
|
||||
/**
|
||||
* Supported content-encoding methods.
|
||||
*/
|
||||
|
||||
exports.methods = {
|
||||
gzip: zlib.createGzip,
|
||||
deflate: zlib.createDeflate
|
||||
};
|
||||
|
||||
/**
|
||||
* Default filter function.
|
||||
*/
|
||||
|
||||
exports.filter = function(req, res){
|
||||
var type = res.getHeader('Content-Type') || '';
|
||||
return type.match(/json|text|javascript/);
|
||||
};
|
||||
|
||||
/**
|
||||
* Compress response data with gzip/deflate.
|
||||
*
|
||||
* Filter:
|
||||
*
|
||||
* A `filter` callback function may be passed to
|
||||
* replace the default logic of:
|
||||
*
|
||||
* exports.filter = function(req, res){
|
||||
* var type = res.getHeader('Content-Type') || '';
|
||||
* return type.match(/json|text|javascript/);
|
||||
* };
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* All remaining options are passed to the gzip/deflate
|
||||
* creation functions. Consult node's docs for additional details.
|
||||
*
|
||||
* - `chunkSize` (default: 16*1024)
|
||||
* - `windowBits`
|
||||
* - `level`: 0-9 where 0 is no compression, and 9 is slow but best compression
|
||||
* - `memLevel`: 1-9 low is slower but uses less memory, high is fast but uses more
|
||||
* - `strategy`: compression strategy
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function compress(options) {
|
||||
var options = options || {}
|
||||
, names = Object.keys(exports.methods)
|
||||
, filter = options.filter || exports.filter;
|
||||
|
||||
return function(req, res, next){
|
||||
var accept = req.headers['accept-encoding']
|
||||
, write = res.write
|
||||
, end = res.end
|
||||
, stream
|
||||
, method;
|
||||
|
||||
// vary
|
||||
res.setHeader('Vary', 'Accept-Encoding');
|
||||
|
||||
// proxy
|
||||
|
||||
res.write = function(chunk, encoding){
|
||||
if (!this.headerSent) this._implicitHeader();
|
||||
return stream
|
||||
? stream.write(chunk, encoding)
|
||||
: write.call(res, chunk, encoding);
|
||||
};
|
||||
|
||||
res.end = function(chunk, encoding){
|
||||
if (chunk) this.write(chunk, encoding);
|
||||
return stream
|
||||
? stream.end()
|
||||
: end.call(res);
|
||||
};
|
||||
|
||||
res.on('header', function(){
|
||||
// default request filter
|
||||
if (!filter(req, res)) return;
|
||||
|
||||
// SHOULD use identity
|
||||
if (!accept) return;
|
||||
|
||||
// head
|
||||
if ('HEAD' == req.method) return;
|
||||
|
||||
// default to gzip
|
||||
if ('*' == accept.trim()) method = 'gzip';
|
||||
|
||||
// compression method
|
||||
if (!method) {
|
||||
for (var i = 0, len = names.length; i < len; ++i) {
|
||||
if (~accept.indexOf(names[i])) {
|
||||
method = names[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// compression method
|
||||
if (!method) return;
|
||||
|
||||
// compression stream
|
||||
stream = exports.methods[method](options);
|
||||
|
||||
// header fields
|
||||
res.setHeader('Content-Encoding', method);
|
||||
res.removeHeader('Content-Length');
|
||||
|
||||
// compression
|
||||
|
||||
stream.on('data', function(chunk){
|
||||
write.call(res, chunk);
|
||||
});
|
||||
|
||||
stream.on('end', function(){
|
||||
end.call(res);
|
||||
});
|
||||
});
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
201
first-project/node_modules/gzippo/lib/staticGzip.js
generated
vendored
Normal file
201
first-project/node_modules/gzippo/lib/staticGzip.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
/*!
|
||||
* Tom Gallacher
|
||||
*
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var fs = require('fs'),
|
||||
parse = require('url').parse,
|
||||
path = require('path'),
|
||||
mime = require('mime'),
|
||||
zlib = require('zlib'),
|
||||
staticSend;
|
||||
try {
|
||||
staticSend = require('connect').static.send;
|
||||
} catch (e) {
|
||||
staticSend = require('express').static.send;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip `Content-*` headers from `res`.
|
||||
*
|
||||
* @param {ServerResponse} res
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var removeContentHeaders = function(res){
|
||||
Object.keys(res._headers).forEach(function(field){
|
||||
if (0 === field.indexOf('content')) {
|
||||
res.removeHeader(field);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* gzipped cache.
|
||||
*/
|
||||
|
||||
var gzippoCache = {};
|
||||
|
||||
/**
|
||||
* gzip file.
|
||||
*/
|
||||
|
||||
var gzippo = function(filename, charset, callback) {
|
||||
|
||||
fs.readFile(filename, function (err, data) {
|
||||
if (err) throw err;
|
||||
zlib.gzip(data, function(err, result) {
|
||||
callback(result);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* By default gzip's static's that match the given regular expression /text|javascript|json/
|
||||
* and then serves them with Connects static provider, denoted by the given `dirPath`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `maxAge` how long gzippo should cache gziped assets, defaulting to 1 day
|
||||
* - `clientMaxAge` client cache-control max-age directive, defaulting to 1 week
|
||||
* - `contentTypeMatch` - A regular expression tested against the Content-Type header to determine whether the response
|
||||
* should be gzipped or not. The default value is `/text|javascript|json/`.
|
||||
* - `prefix` - A url prefix. If you want all your static content in a root path such as /resource/. Any url paths not matching will be ignored
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* connect.createServer(
|
||||
* connect.staticGzip(__dirname + '/public/');
|
||||
* );
|
||||
*
|
||||
* connect.createServer(
|
||||
* connect.staticGzip(__dirname + '/public/', {maxAge: 86400000});
|
||||
* );
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} options
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports = module.exports = function staticGzip(dirPath, options){
|
||||
options = options || {};
|
||||
var
|
||||
maxAge = options.maxAge || 86400000,
|
||||
contentTypeMatch = options.contentTypeMatch || /text|javascript|json/,
|
||||
clientMaxAge = options.clientMaxAge || 604800000,
|
||||
prefix = options.prefix || '';
|
||||
|
||||
if (!dirPath) throw new Error('You need to provide the directory to your static content.');
|
||||
if (!contentTypeMatch.test) throw new Error('contentTypeMatch: must be a regular expression.');
|
||||
|
||||
return function staticGzip(req, res, next){
|
||||
var url, filename, contentType, acceptEncoding, charset;
|
||||
|
||||
function pass(name) {
|
||||
var o = Object.create(options);
|
||||
o.path = name;
|
||||
o.maxAge = clientMaxAge;
|
||||
staticSend(req, res, next, o);
|
||||
}
|
||||
|
||||
function setHeaders(cacheObj) {
|
||||
res.setHeader('Content-Type', contentType);
|
||||
res.setHeader('Content-Encoding', 'gzip');
|
||||
res.setHeader('Vary', 'Accept-Encoding');
|
||||
res.setHeader('Content-Length', cacheObj.content.length);
|
||||
res.setHeader('Last-Modified', cacheObj.mtime.toUTCString());
|
||||
res.setHeader('Date', new Date().toUTCString());
|
||||
res.setHeader('Expires', new Date(Date.now() + clientMaxAge).toUTCString());
|
||||
res.setHeader('Cache-Control', 'public, max-age=' + (clientMaxAge / 1000));
|
||||
res.setHeader('ETag', '"' + cacheObj.content.length + '-' + Number(cacheObj.mtime) + '"');
|
||||
}
|
||||
|
||||
function sendGzipped(cacheObj) {
|
||||
setHeaders(cacheObj);
|
||||
res.end(cacheObj.content, 'binary');
|
||||
}
|
||||
|
||||
function gzipAndSend(filename, gzipName, mtime) {
|
||||
gzippo(filename, charset, function(gzippedData) {
|
||||
gzippoCache[gzipName] = {
|
||||
'ctime': Date.now(),
|
||||
'mtime': mtime,
|
||||
'content': gzippedData
|
||||
};
|
||||
sendGzipped(gzippoCache[gzipName]);
|
||||
});
|
||||
}
|
||||
|
||||
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
||||
return next();
|
||||
}
|
||||
|
||||
url = parse(req.url);
|
||||
|
||||
// Allow a url path prefix
|
||||
if (url.pathname.substring(0, prefix.length) !== prefix) {
|
||||
return next();
|
||||
}
|
||||
|
||||
filename = path.join(dirPath, url.pathname.substring(prefix.length));
|
||||
|
||||
contentType = mime.lookup(filename);
|
||||
charset = mime.charsets.lookup(contentType, 'UTF-8');
|
||||
contentType = contentType + (charset ? '; charset=' + charset : '');
|
||||
acceptEncoding = req.headers['accept-encoding'] || '';
|
||||
|
||||
//This is storing in memory for the moment, need to think what the best way to do this.
|
||||
//Check file is not a directory
|
||||
|
||||
fs.stat(decodeURI(filename), function(err, stat) {
|
||||
if (err) {
|
||||
return pass(filename);
|
||||
}
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
return pass(req.url);
|
||||
}
|
||||
|
||||
if (!contentTypeMatch.test(contentType)) {
|
||||
return pass(filename);
|
||||
}
|
||||
|
||||
if (!~acceptEncoding.indexOf('gzip')) {
|
||||
return pass(filename);
|
||||
}
|
||||
|
||||
var base = path.basename(filename),
|
||||
dir = path.dirname(filename),
|
||||
gzipName = path.join(dir, base + '.gz');
|
||||
|
||||
if (req.headers['if-modified-since'] &&
|
||||
gzippoCache[gzipName] &&
|
||||
+stat.mtime <= new Date(req.headers['if-modified-since']).getTime()) {
|
||||
setHeaders(gzippoCache[gzipName]);
|
||||
removeContentHeaders(res);
|
||||
res.statusCode = 304;
|
||||
return res.end();
|
||||
}
|
||||
|
||||
//TODO: check for pre-compressed file
|
||||
if (typeof gzippoCache[gzipName] === 'undefined') {
|
||||
gzipAndSend(filename, gzipName, stat.mtime);
|
||||
} else {
|
||||
if ((gzippoCache[gzipName].mtime < stat.mtime) ||
|
||||
((gzippoCache[gzipName].ctime + maxAge) < Date.now())) {
|
||||
gzipAndSend(filename, gzipName, stat.mtime);
|
||||
} else {
|
||||
sendGzipped(gzippoCache[gzipName]);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
19
first-project/node_modules/gzippo/node_modules/mime/LICENSE
generated
vendored
Normal file
19
first-project/node_modules/gzippo/node_modules/mime/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
|
||||
|
||||
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.
|
||||
63
first-project/node_modules/gzippo/node_modules/mime/README.md
generated
vendored
Normal file
63
first-project/node_modules/gzippo/node_modules/mime/README.md
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# mime
|
||||
|
||||
Comprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](http://github.com/isaacs/npm):
|
||||
|
||||
npm install mime
|
||||
|
||||
## API - Queries
|
||||
|
||||
### mime.lookup(path)
|
||||
Get the mime type associated with a file. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.
|
||||
|
||||
var mime = require('mime');
|
||||
|
||||
mime.lookup('/path/to/file.txt'); // => 'text/plain'
|
||||
mime.lookup('file.txt'); // => 'text/plain'
|
||||
mime.lookup('.TXT'); // => 'text/plain'
|
||||
mime.lookup('htm'); // => 'text/html'
|
||||
|
||||
### mime.extension(type)
|
||||
Get the default extension for `type`
|
||||
|
||||
mime.extension('text/html'); // => 'html'
|
||||
mime.extension('application/octet-stream'); // => 'bin'
|
||||
|
||||
### mime.charsets.lookup()
|
||||
|
||||
Map mime-type to charset
|
||||
|
||||
mime.charsets.lookup('text/plain'); // => 'UTF-8'
|
||||
|
||||
(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)
|
||||
|
||||
## API - Defining Custom Types
|
||||
|
||||
The following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/bentomas/node-mime/wiki/Requesting-New-Types).
|
||||
|
||||
### mime.define()
|
||||
|
||||
Add custom mime/extension mappings
|
||||
|
||||
mime.define({
|
||||
'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
|
||||
'application/x-my-type': ['x-mt', 'x-mtt'],
|
||||
// etc ...
|
||||
});
|
||||
|
||||
mime.lookup('x-sft'); // => 'text/x-some-format'
|
||||
|
||||
The first entry in the extensions array is returned by `mime.extension()`. E.g.
|
||||
|
||||
mime.extension('text/x-some-format'); // => 'x-sf'
|
||||
|
||||
### mime.load(filepath)
|
||||
|
||||
Load mappings from an Apache ".types" format file
|
||||
|
||||
mime.load('./my_project.types');
|
||||
|
||||
The .types file format is simple - See the `types` dir for examples.
|
||||
93
first-project/node_modules/gzippo/node_modules/mime/mime.js
generated
vendored
Normal file
93
first-project/node_modules/gzippo/node_modules/mime/mime.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
var path = require('path'),
|
||||
fs = require('fs');
|
||||
|
||||
var mime = module.exports = {
|
||||
// Map of extension to mime type
|
||||
types: Object.create(null),
|
||||
|
||||
// Map of mime type to extension
|
||||
extensions :Object.create(null),
|
||||
|
||||
/**
|
||||
* Define mimetype -> extension mappings. Each key is a mime-type that maps
|
||||
* to an array of extensions associated with the type. The first extension is
|
||||
* used as the default extension for the type.
|
||||
*
|
||||
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
|
||||
*
|
||||
* @param map (Object) type definitions
|
||||
*/
|
||||
define: function(map) {
|
||||
for (var type in map) {
|
||||
var exts = map[type];
|
||||
|
||||
for (var i = 0; i < exts.length; i++) {
|
||||
mime.types[exts[i]] = type;
|
||||
}
|
||||
|
||||
// Default extension is the first one we encounter
|
||||
if (!mime.extensions[type]) {
|
||||
mime.extensions[type] = exts[0];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Load an Apache2-style ".types" file
|
||||
*
|
||||
* This may be called multiple times (it's expected). Where files declare
|
||||
* overlapping types/extensions, the last file wins.
|
||||
*
|
||||
* @param file (String) path of file to load.
|
||||
*/
|
||||
load: function(file) {
|
||||
// Read file and split into lines
|
||||
var map = {},
|
||||
content = fs.readFileSync(file, 'ascii'),
|
||||
lines = content.split(/[\r\n]+/);
|
||||
|
||||
lines.forEach(function(line, lineno) {
|
||||
// Clean up whitespace/comments, and split into fields
|
||||
var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
|
||||
map[fields.shift()] = fields;
|
||||
});
|
||||
|
||||
mime.define(map);
|
||||
},
|
||||
|
||||
/**
|
||||
* Lookup a mime type based on extension
|
||||
*/
|
||||
lookup: function(path, fallback) {
|
||||
var ext = path.replace(/.*[\.\/]/, '').toLowerCase();
|
||||
|
||||
return mime.types[ext] || fallback || mime.default_type
|
||||
},
|
||||
|
||||
/**
|
||||
* Return file extension associated with a mime type
|
||||
*/
|
||||
extension: function(mimeType) {
|
||||
return mime.extensions[mimeType];
|
||||
},
|
||||
|
||||
/**
|
||||
* Lookup a charset based on mime type.
|
||||
*/
|
||||
charsets: {
|
||||
lookup: function (mimeType, fallback) {
|
||||
// Assume text types are utf8. Modify mime logic as needed.
|
||||
return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Load our local copy of
|
||||
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
mime.load(path.join(__dirname, 'types/mime.types'));
|
||||
|
||||
// Overlay enhancements submitted by the node.js community
|
||||
mime.load(path.join(__dirname, 'types/node.types'));
|
||||
|
||||
// Set the default type
|
||||
mime.default_type = mime.types.bin;
|
||||
38
first-project/node_modules/gzippo/node_modules/mime/package.json
generated
vendored
Normal file
38
first-project/node_modules/gzippo/node_modules/mime/package.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Robert Kieffer",
|
||||
"email": "robert@broofa.com",
|
||||
"url": "http://github.com/broofa"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Benjamin Thomas",
|
||||
"email": "benjamin@benjaminthomas.org",
|
||||
"url": "http://github.com/bentomas"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "A comprehensive library for mime-type mapping",
|
||||
"devDependencies": {},
|
||||
"keywords": [
|
||||
"util",
|
||||
"mime"
|
||||
],
|
||||
"main": "mime.js",
|
||||
"name": "mime",
|
||||
"repository": {
|
||||
"url": "git://github.com/bentomas/node-mime.git",
|
||||
"type": "git"
|
||||
},
|
||||
"version": "1.2.5",
|
||||
"_id": "mime@1.2.5",
|
||||
"optionalDependencies": {},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"_engineSupported": true,
|
||||
"_npmVersion": "1.1.21",
|
||||
"_nodeVersion": "v0.6.18",
|
||||
"_defaultsLoaded": true,
|
||||
"_from": "mime@>= 1.2"
|
||||
}
|
||||
53
first-project/node_modules/gzippo/node_modules/mime/test.js
generated
vendored
Normal file
53
first-project/node_modules/gzippo/node_modules/mime/test.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Usage: node test.js
|
||||
*/
|
||||
|
||||
var mime = require('./mime');
|
||||
var assert = require('assert');
|
||||
|
||||
function eq(a, b) {
|
||||
console.log('Test: ' + a + ' === ' + b);
|
||||
assert.strictEqual.apply(null, arguments);
|
||||
}
|
||||
|
||||
console.log(Object.keys(mime.extensions).length + ' types');
|
||||
console.log(Object.keys(mime.types).length + ' extensions\n');
|
||||
|
||||
//
|
||||
// Test mime lookups
|
||||
//
|
||||
|
||||
eq('text/plain', mime.lookup('text.txt'));
|
||||
eq('text/plain', mime.lookup('.text.txt'));
|
||||
eq('text/plain', mime.lookup('.txt'));
|
||||
eq('text/plain', mime.lookup('txt'));
|
||||
eq('application/octet-stream', mime.lookup('text.nope'));
|
||||
eq('fallback', mime.lookup('text.fallback', 'fallback'));
|
||||
eq('application/octet-stream', mime.lookup('constructor'));
|
||||
eq('text/plain', mime.lookup('TEXT.TXT'));
|
||||
|
||||
//
|
||||
// Test extensions
|
||||
//
|
||||
|
||||
eq('txt', mime.extension(mime.types.text));
|
||||
eq('html', mime.extension(mime.types.htm));
|
||||
eq('bin', mime.extension('application/octet-stream'));
|
||||
eq(undefined, mime.extension('constructor'));
|
||||
|
||||
//
|
||||
// Test node types
|
||||
//
|
||||
|
||||
eq('application/octet-stream', mime.lookup('file.buffer'));
|
||||
eq('audio/mp4', mime.lookup('file.m4a'));
|
||||
|
||||
//
|
||||
// Test charsets
|
||||
//
|
||||
|
||||
eq('UTF-8', mime.charsets.lookup('text/plain'));
|
||||
eq(undefined, mime.charsets.lookup(mime.types.js));
|
||||
eq('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
|
||||
|
||||
console.log('\nOK');
|
||||
1510
first-project/node_modules/gzippo/node_modules/mime/types/mime.types
generated
vendored
Normal file
1510
first-project/node_modules/gzippo/node_modules/mime/types/mime.types
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
48
first-project/node_modules/gzippo/node_modules/mime/types/node.types
generated
vendored
Normal file
48
first-project/node_modules/gzippo/node_modules/mime/types/node.types
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# What: Google Chrome Extension
|
||||
# Why: To allow apps to (work) be served with the right content type header.
|
||||
# http://codereview.chromium.org/2830017
|
||||
# Added by: niftylettuce
|
||||
application/x-chrome-extension crx
|
||||
|
||||
# What: OTF Message Silencer
|
||||
# Why: To silence the "Resource interpreted as font but transferred with MIME
|
||||
# type font/otf" message that occurs in Google Chrome
|
||||
# Added by: niftylettuce
|
||||
font/opentype otf
|
||||
|
||||
# What: HTC support
|
||||
# Why: To properly render .htc files such as CSS3PIE
|
||||
# Added by: niftylettuce
|
||||
text/x-component htc
|
||||
|
||||
# What: HTML5 application cache manifest
|
||||
# Why: De-facto standard. Required by Mozilla browser when serving HTML5 apps
|
||||
# per https://developer.mozilla.org/en/offline_resources_in_firefox
|
||||
# Added by: louisremi
|
||||
text/cache-manifest appcache manifest
|
||||
|
||||
# What: node binary buffer format
|
||||
# Why: semi-standard extension w/in the node community
|
||||
# Added by: tootallnate
|
||||
application/octet-stream buffer
|
||||
|
||||
# What: The "protected" MP-4 formats used by iTunes.
|
||||
# Why: Required for streaming music to browsers (?)
|
||||
# Added by: broofa
|
||||
application/mp4 m4p
|
||||
audio/mp4 m4a
|
||||
|
||||
# What: Music playlist format (http://en.wikipedia.org/wiki/M3U)
|
||||
# Why: See https://github.com/bentomas/node-mime/pull/6
|
||||
# Added by: mjrusso
|
||||
application/x-mpegURL m3u8
|
||||
|
||||
# What: Video format, Part of RFC1890
|
||||
# Why: See https://github.com/bentomas/node-mime/pull/6
|
||||
# Added by: mjrusso
|
||||
video/MP2T ts
|
||||
|
||||
# What: The FLAC lossless codec format
|
||||
# Why: Streaming and serving FLAC audio
|
||||
# Added by: jacobrask
|
||||
audio/flac flac
|
||||
44
first-project/node_modules/gzippo/package.json
generated
vendored
Normal file
44
first-project/node_modules/gzippo/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "gzippo",
|
||||
"version": "0.1.4",
|
||||
"author": {
|
||||
"name": "Tom Gallacher"
|
||||
},
|
||||
"description": "Gzip middleware for Connect using the native zlib library in node >= 0.6",
|
||||
"homepage": "http://www.tomg.co/gzippo",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/tomgco/gzippo.git"
|
||||
},
|
||||
"keywords": [
|
||||
"compession",
|
||||
"gzip",
|
||||
"compess"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.5 < 0.7"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "expresso"
|
||||
},
|
||||
"main": "./index.js",
|
||||
"dependencies": {
|
||||
"mime": ">= 1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"expresso": ">= 0.9",
|
||||
"should": ">= 0.3",
|
||||
"connect": ">= 1.8",
|
||||
"express": ">= 2.5"
|
||||
},
|
||||
"_id": "gzippo@0.1.4",
|
||||
"optionalDependencies": {},
|
||||
"_engineSupported": true,
|
||||
"_npmVersion": "1.1.21",
|
||||
"_nodeVersion": "v0.6.18",
|
||||
"_defaultsLoaded": true,
|
||||
"dist": {
|
||||
"shasum": "5ae0e5f3bba354506a96b373388dd06691697163"
|
||||
},
|
||||
"_from": "gzippo@>=0.1.4"
|
||||
}
|
||||
0
first-project/node_modules/gzippo/test/fixtures/js/nestedTest.js
generated
vendored
Normal file
0
first-project/node_modules/gzippo/test/fixtures/js/nestedTest.js
generated
vendored
Normal file
BIN
first-project/node_modules/gzippo/test/fixtures/space the final frontier/tomg.co.png
generated
vendored
Normal file
BIN
first-project/node_modules/gzippo/test/fixtures/space the final frontier/tomg.co.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
1
first-project/node_modules/gzippo/test/fixtures/test.js
generated
vendored
Normal file
1
first-project/node_modules/gzippo/test/fixtures/test.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
alert("hello");
|
||||
BIN
first-project/node_modules/gzippo/test/fixtures/test.js.gzip
generated
vendored
Normal file
BIN
first-project/node_modules/gzippo/test/fixtures/test.js.gzip
generated
vendored
Normal file
Binary file not shown.
BIN
first-project/node_modules/gzippo/test/fixtures/tomg.co.png
generated
vendored
Normal file
BIN
first-project/node_modules/gzippo/test/fixtures/tomg.co.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
first-project/node_modules/gzippo/test/fixtures/user.gzip
generated
vendored
Normal file
BIN
first-project/node_modules/gzippo/test/fixtures/user.gzip
generated
vendored
Normal file
Binary file not shown.
4
first-project/node_modules/gzippo/test/fixtures/user.json
generated
vendored
Normal file
4
first-project/node_modules/gzippo/test/fixtures/user.json
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "tomgallacher",
|
||||
"website": "www.tomgallacher.info"
|
||||
}
|
||||
0
first-project/node_modules/gzippo/test/fixtures/utf8.gz
generated
vendored
Normal file
0
first-project/node_modules/gzippo/test/fixtures/utf8.gz
generated
vendored
Normal file
32
first-project/node_modules/gzippo/test/fixtures/utf8.txt
generated
vendored
Normal file
32
first-project/node_modules/gzippo/test/fixtures/utf8.txt
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
English: The quick brown fox jumps over the lazy dog.
|
||||
Jamaican: Chruu, a kwik di kwik brong fox a jomp huova di liezi daag de, yu no siit?
|
||||
Irish: "An ḃfuil do ċroí ag bualaḋ ó ḟaitíos an ġrá a ṁeall lena ṗóg éada ó ṡlí do leasa ṫú?" "D'ḟuascail Íosa Úrṁac na hÓiġe Beannaiṫe pór Éava agus Áḋaiṁ."
|
||||
Dutch: Pa's wijze lynx bezag vroom het fikse aquaduct.
|
||||
German: Falsches Üben von Xylophonmusik quält jeden größeren Zwerg. (1)
|
||||
German: Im finſteren Jagdſchloß am offenen Felsquellwaſſer patzte der affig-flatterhafte kauzig-höfliche Bäcker über ſeinem verſifften kniffligen C-Xylophon. (2)
|
||||
Norwegian: Blåbærsyltetøy ("blueberry jam", includes every extra letter used in Norwegian).
|
||||
Swedish: Flygande bäckasiner söka strax hwila på mjuka tuvor.
|
||||
Icelandic: Sævör grét áðan því úlpan var ónýt.
|
||||
Finnish: (5) Törkylempijävongahdus (This is a perfect pangram, every letter appears only once. Translating it is an art on its own, but I'll say "rude lover's yelp". :-D)
|
||||
Finnish: (5) Albert osti fagotin ja töräytti puhkuvan melodian. (Albert bought a bassoon and hooted an impressive melody.)
|
||||
Finnish: (5) On sangen hauskaa, että polkupyörä on maanteiden jokapäiväinen ilmiö. (It's pleasantly amusing, that the bicycle is an everyday sight on the roads.)
|
||||
Polish: Pchnąć w tę łódź jeża lub osiem skrzyń fig.
|
||||
Czech: Příliš žluťoučký kůň úpěl ďábelské kódy.
|
||||
Slovak: Starý kôň na hŕbe kníh žuje tíško povädnuté ruže, na stĺpe sa ďateľ učí kvákať novú ódu o živote.
|
||||
Greek (monotonic): ξεσκεπάζω την ψυχοφθόρα βδελυγμία
|
||||
Greek (polytonic): ξεσκεπάζω τὴν ψυχοφθόρα βδελυγμία
|
||||
Russian: Съешь же ещё этих мягких французских булок да выпей чаю.
|
||||
Russian: В чащах юга жил-был цитрус? Да, но фальшивый экземпляр! ёъ.
|
||||
Bulgarian: Жълтата дюля беше щастлива, че пухът, който цъфна, замръзна като гьон.
|
||||
Sami (Northern): Vuol Ruoŧa geđggiid leat máŋga luosa ja čuovžža.
|
||||
Hungarian: Árvíztűrő tükörfúrógép.
|
||||
Spanish: El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su querido cachorro.
|
||||
Portuguese: O próximo vôo à noite sobre o Atlântico, põe freqüentemente o único médico. (3)
|
||||
French: Les naïfs ægithales hâtifs pondant à Noël où il gèle sont sûrs d'être déçus en voyant leurs drôles d'œufs abîmés.
|
||||
Esperanto: Eĥoŝanĝo ĉiuĵaŭde.
|
||||
Hebrew: זה כיף סתם לשמוע איך תנצח קרפד עץ טוב בגן.
|
||||
Japanese (Hiragana):
|
||||
いろはにほへど ちりぬるを
|
||||
わがよたれぞ つねならむ
|
||||
うゐのおくやま けふこえて
|
||||
あさきゆめみじ ゑひもせず (4)
|
||||
BIN
first-project/node_modules/gzippo/test/fixtures/utf8.txt.gz
generated
vendored
Normal file
BIN
first-project/node_modules/gzippo/test/fixtures/utf8.txt.gz
generated
vendored
Normal file
Binary file not shown.
88
first-project/node_modules/gzippo/test/prefexTest.js
generated
vendored
Normal file
88
first-project/node_modules/gzippo/test/prefexTest.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var staticProvider,
|
||||
assert = require('assert'),
|
||||
should = require('should'),
|
||||
http = require('http'),
|
||||
gzippo = require('../');
|
||||
|
||||
try {
|
||||
staticProvider = require('connect');
|
||||
} catch (e) {
|
||||
staticProvider = require('express');
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to ./test/fixtures/
|
||||
*/
|
||||
|
||||
var fixturesPath = __dirname + '/fixtures';
|
||||
|
||||
module.exports = {
|
||||
'requesting without a prefix succeeds': function() {
|
||||
var app = staticProvider.createServer(
|
||||
gzippo.staticGzip(fixturesPath)
|
||||
);
|
||||
|
||||
assert.response(app,
|
||||
{
|
||||
url: '/user.json',
|
||||
headers: {
|
||||
'Accept-Encoding':"gzip"
|
||||
}
|
||||
},
|
||||
function(res){
|
||||
var gzippedData = res.body;
|
||||
res.statusCode.should.equal(200);
|
||||
res.headers.should.have.property('content-type', 'application/json; charset=UTF-8');
|
||||
res.headers.should.have.property('content-length', '69');
|
||||
res.headers.should.have.property('content-encoding', 'gzip');
|
||||
}
|
||||
);
|
||||
},
|
||||
'requesting with a prefix succeeds': function() {
|
||||
var app = staticProvider.createServer(
|
||||
gzippo.staticGzip(fixturesPath, { prefix: '/resource' })
|
||||
);
|
||||
|
||||
assert.response(app,
|
||||
{
|
||||
url: '/resource/user.json',
|
||||
headers: {
|
||||
'Accept-Encoding':"gzip"
|
||||
}
|
||||
},
|
||||
function(res){
|
||||
var gzippedData = res.body;
|
||||
res.statusCode.should.equal(200);
|
||||
res.headers.should.have.property('content-type', 'application/json; charset=UTF-8');
|
||||
res.headers.should.have.property('content-length', '69');
|
||||
res.headers.should.have.property('content-encoding', 'gzip');
|
||||
}
|
||||
);
|
||||
},
|
||||
'requesting with a / prefix succeeds': function() {
|
||||
var app = staticProvider.createServer(
|
||||
gzippo.staticGzip(fixturesPath, { prefix: '/'})
|
||||
);
|
||||
|
||||
assert.response(app,
|
||||
{
|
||||
url: '/user.json',
|
||||
headers: {
|
||||
'Accept-Encoding':"gzip"
|
||||
}
|
||||
},
|
||||
function(res){
|
||||
var gzippedData = res.body;
|
||||
res.statusCode.should.equal(200);
|
||||
res.headers.should.have.property('content-type', 'application/json; charset=UTF-8');
|
||||
res.headers.should.have.property('content-length', '69');
|
||||
res.headers.should.have.property('content-encoding', 'gzip');
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
190
first-project/node_modules/gzippo/test/staticGzipTest.js
generated
vendored
Normal file
190
first-project/node_modules/gzippo/test/staticGzipTest.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var staticProvider,
|
||||
assert = require('assert'),
|
||||
should = require('should'),
|
||||
http = require('http'),
|
||||
gzippo = require('../'),
|
||||
crypto = require('crypto'),
|
||||
fs = require('fs'),
|
||||
shasum = crypto.createHash('sha1');
|
||||
|
||||
try {
|
||||
staticProvider = require('connect');
|
||||
} catch (e) {
|
||||
staticProvider = require('express');
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to ./test/fixtures/
|
||||
*/
|
||||
|
||||
var fixturesPath = __dirname + '/fixtures';
|
||||
|
||||
function getApp() {
|
||||
return staticProvider.createServer(gzippo.staticGzip(fixturesPath));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
'requesting gzipped json file succeeds': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/user.json',
|
||||
headers: {
|
||||
'Accept-Encoding':"gzip"
|
||||
}
|
||||
},
|
||||
function(res){
|
||||
var gzippedData = res.body;
|
||||
assert.response(getApp(), { url: '/user.gzip' }, function(res) {
|
||||
assert.equal(gzippedData, res.body, "Data is not gzipped");
|
||||
});
|
||||
res.statusCode.should.equal(200);
|
||||
res.headers.should.have.property('content-type', 'application/json; charset=UTF-8');
|
||||
res.headers.should.have.property('content-length', '69');
|
||||
res.headers.should.have.property('content-encoding', 'gzip');
|
||||
}
|
||||
);
|
||||
},
|
||||
'requesting gzipped js file succeeds': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/test.js',
|
||||
headers: {
|
||||
'Accept-Encoding':"gzip"
|
||||
}
|
||||
},
|
||||
function(res){
|
||||
var gzippedData = res.body;
|
||||
assert.response(getApp(), { url: '/test.js.gzip' }, function(res) {
|
||||
assert.equal(gzippedData, res.body, "Data is not gzipped");
|
||||
});
|
||||
|
||||
res.statusCode.should.equal(200);
|
||||
res.headers.should.have.property('content-type', 'application/javascript; charset=UTF-8');
|
||||
res.headers.should.have.property('content-length', '35');
|
||||
res.headers.should.have.property('content-encoding', 'gzip');
|
||||
}
|
||||
);
|
||||
},
|
||||
'requesting js file without gzip succeeds': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/test.js'
|
||||
},
|
||||
function(res){
|
||||
var gzippedData = res.body;
|
||||
|
||||
fs.readFile(fixturesPath + '/test.js', function (err, data) {
|
||||
if (err) throw err;
|
||||
assert.equal(gzippedData, data, "Data returned does not match file data on filesystem");
|
||||
});
|
||||
|
||||
res.statusCode.should.equal(200);
|
||||
res.headers.should.have.property('content-length', '15');
|
||||
}
|
||||
);
|
||||
},
|
||||
'requesting gzipped utf-8 file succeeds': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/utf8.txt',
|
||||
headers: {
|
||||
'Accept-Encoding':"gzip"
|
||||
}
|
||||
},
|
||||
function(res){
|
||||
var gzippedData = res.body;
|
||||
assert.response(getApp(), { url: '/utf8.txt.gz' }, function(res) {
|
||||
assert.equal(gzippedData, res.body, "Data is not gzipped");
|
||||
});
|
||||
|
||||
res.statusCode.should.equal(200);
|
||||
res.headers.should.have.property('content-type', 'text/plain; charset=UTF-8');
|
||||
res.headers.should.have.property('content-length', '2031');
|
||||
res.headers.should.have.property('content-encoding', 'gzip');
|
||||
}
|
||||
);
|
||||
},
|
||||
'requesting gzipped utf-8 file returns 304': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/utf8.txt',
|
||||
headers: {
|
||||
'Accept-Encoding': "gzip"
|
||||
}
|
||||
},
|
||||
function(res) {
|
||||
res.statusCode.should.equal(200);
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/utf8.txt',
|
||||
headers: {
|
||||
'Accept-Encoding': "gzip",
|
||||
'If-Modified-Since': res.headers['last-modified']
|
||||
}
|
||||
},
|
||||
function(res2) {
|
||||
res2.statusCode.should.equal(304);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
'requesting gzipped utf-8 file returns 200': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/utf8.txt',
|
||||
headers: {
|
||||
'Accept-Encoding': "gzip"
|
||||
}
|
||||
},
|
||||
function(res) {
|
||||
res.statusCode.should.equal(200);
|
||||
}
|
||||
);
|
||||
},
|
||||
'ensuring max age is set on resources which are passed to the default static content provider': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/tomg.co.png'
|
||||
},
|
||||
function(res) {
|
||||
res.headers.should.have.property('cache-control', 'public, max-age=604800');
|
||||
}
|
||||
);
|
||||
},
|
||||
'Ensuring that when viewing a directory a redirect works correctly': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/js'
|
||||
},
|
||||
function(res) {
|
||||
res.statusCode.should.not.equal(301);
|
||||
}
|
||||
);
|
||||
},
|
||||
'ensuring that gzippo works with a space in a static content path': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/space%20the%20final%20frontier/tomg.co.png'
|
||||
},
|
||||
function(res) {
|
||||
res.statusCode.should.not.equal(404);
|
||||
}
|
||||
);
|
||||
},
|
||||
'Ensuring req.url isnt passed to staticSend on error': function() {
|
||||
assert.response(getApp(),
|
||||
{
|
||||
url: '/etc/passwd'
|
||||
},
|
||||
function(res) {
|
||||
res.statusCode.should.equal(404);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user