mirror of
https://github.com/arnaucube/comunicationLeap.git
synced 2026-02-07 03:16:45 +01:00
nodejs with express server, leapmotion for movement control, and threejs for 3d render
This commit is contained in:
4
node_modules/send/.npmignore
generated
vendored
Normal file
4
node_modules/send/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
support
|
||||
test
|
||||
examples
|
||||
*.sock
|
||||
25
node_modules/send/History.md
generated
vendored
Normal file
25
node_modules/send/History.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
0.1.0 / 2012-08-25
|
||||
==================
|
||||
|
||||
* add options parameter to send() that is passed to fs.createReadStream() [kanongil]
|
||||
|
||||
0.0.4 / 2012-08-16
|
||||
==================
|
||||
|
||||
* allow custom "Accept-Ranges" definition
|
||||
|
||||
0.0.3 / 2012-07-16
|
||||
==================
|
||||
|
||||
* fix normalization of the root directory. Closes #3
|
||||
|
||||
0.0.2 / 2012-07-09
|
||||
==================
|
||||
|
||||
* add passing of req explicitly for now (YUCK)
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
8
node_modules/send/Makefile
generated
vendored
Normal file
8
node_modules/send/Makefile
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--require should \
|
||||
--reporter spec \
|
||||
--bail
|
||||
|
||||
.PHONY: test
|
||||
123
node_modules/send/Readme.md
generated
vendored
Normal file
123
node_modules/send/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
|
||||
# send
|
||||
|
||||
Send is Connect's `static()` extracted for generalized use, a streaming static file
|
||||
server supporting partial responses (Ranges), conditional-GET negotiation, high test coverage, and granular events which may be leveraged to take appropriate actions in your application or framework.
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install send
|
||||
|
||||
## Examples
|
||||
|
||||
Small:
|
||||
|
||||
```js
|
||||
var http = require('http');
|
||||
var send = require('send');
|
||||
|
||||
var app = http.createServer(function(req, res){
|
||||
send(req, req.url).pipe(res);
|
||||
});
|
||||
```
|
||||
|
||||
Serving from a root directory with custom error-handling:
|
||||
|
||||
```js
|
||||
var http = require('http');
|
||||
var send = require('send');
|
||||
|
||||
var app = http.createServer(function(req, res){
|
||||
// your custom error-handling logic:
|
||||
function error(err) {
|
||||
res.statusCode = err.status || 500;
|
||||
res.end(err.message);
|
||||
}
|
||||
|
||||
// your custom directory handling logic:
|
||||
function redirect() {
|
||||
res.statusCode = 301;
|
||||
res.setHeader('Location', req.url + '/');
|
||||
res.end('Redirecting to ' + req.url + '/');
|
||||
}
|
||||
|
||||
// transfer arbitrary files from within
|
||||
// /www/example.com/public/*
|
||||
send(req, url.parse(req.url).pathname)
|
||||
.root('/www/example.com/public')
|
||||
.on('error', error)
|
||||
.on('directory', redirect)
|
||||
.pipe(res);
|
||||
});
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Events
|
||||
|
||||
- `error` an error occurred `(err)`
|
||||
- `directory` a directory was requested
|
||||
- `stream` file streaming has started `(stream)`
|
||||
- `end` streaming has completed
|
||||
|
||||
### .root(dir)
|
||||
|
||||
Serve files relative to `path`. Aliased as `.from(dir)`.
|
||||
|
||||
### .index(path)
|
||||
|
||||
By default send supports "index.html" files, to disable this
|
||||
invoke `.index(false)` or to supply a new index pass a string.
|
||||
|
||||
### .maxage(ms)
|
||||
|
||||
Provide a max-age in milliseconds for http caching, defaults to 0.
|
||||
|
||||
## Error-handling
|
||||
|
||||
By default when no `error` listeners are present an automatic response will be made, otherwise you have full control over the response, aka you may show a 5xx page etc.
|
||||
|
||||
## Caching
|
||||
|
||||
It does _not_ perform internal caching, you should use a reverse proxy cache such
|
||||
as Varnish for this, or those fancy things called CDNs. If your application is small enough that it would benefit from single-node memory caching, it's small enough that it does not need caching at all ;).
|
||||
|
||||
## Debugging
|
||||
|
||||
To enable `debug()` instrumentation output export __DEBUG__:
|
||||
|
||||
```
|
||||
$ DEBUG=send node app
|
||||
```
|
||||
|
||||
## Running tests
|
||||
|
||||
```
|
||||
$ npm install
|
||||
$ make test
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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
node_modules/send/index.js
generated
vendored
Normal file
2
node_modules/send/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
module.exports = require('./lib/send');
|
||||
473
node_modules/send/lib/send.js
generated
vendored
Normal file
473
node_modules/send/lib/send.js
generated
vendored
Normal file
@@ -0,0 +1,473 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var debug = require('debug')('send')
|
||||
, parseRange = require('range-parser')
|
||||
, Stream = require('stream')
|
||||
, mime = require('mime')
|
||||
, fresh = require('fresh')
|
||||
, path = require('path')
|
||||
, http = require('http')
|
||||
, fs = require('fs')
|
||||
, basename = path.basename
|
||||
, normalize = path.normalize
|
||||
, join = path.join
|
||||
, utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Expose `send`.
|
||||
*/
|
||||
|
||||
exports = module.exports = send;
|
||||
|
||||
/**
|
||||
* Expose mime module.
|
||||
*/
|
||||
|
||||
exports.mime = mime;
|
||||
|
||||
/**
|
||||
* Return a `SendStream` for `req` and `path`.
|
||||
*
|
||||
* @param {Request} req
|
||||
* @param {String} path
|
||||
* @param {Object} options
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function send(req, path, options) {
|
||||
return new SendStream(req, path, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a `SendStream` with the given `path`.
|
||||
*
|
||||
* Events:
|
||||
*
|
||||
* - `error` an error occurred
|
||||
* - `stream` file streaming has started
|
||||
* - `end` streaming has completed
|
||||
* - `directory` a directory was requested
|
||||
*
|
||||
* @param {Request} req
|
||||
* @param {String} path
|
||||
* @param {Object} options
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function SendStream(req, path, options) {
|
||||
var self = this;
|
||||
this.req = req;
|
||||
this.path = path;
|
||||
this.options = options || {};
|
||||
this.maxage(0);
|
||||
this.hidden(false);
|
||||
this.index('index.html');
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from `Stream.prototype`.
|
||||
*/
|
||||
|
||||
SendStream.prototype.__proto__ = Stream.prototype;
|
||||
|
||||
/**
|
||||
* Enable or disable "hidden" (dot) files.
|
||||
*
|
||||
* @param {Boolean} path
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.hidden = function(val){
|
||||
debug('hidden %s', val);
|
||||
this._hidden = val;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set index `path`, set to a falsy
|
||||
* value to disable index support.
|
||||
*
|
||||
* @param {String|Boolean} path
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.index = function(path){
|
||||
debug('index %s', path);
|
||||
this._index = path;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set root `path`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.root =
|
||||
SendStream.prototype.from = function(path){
|
||||
this._root = normalize(path);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set max-age to `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.maxage = function(ms){
|
||||
if (Infinity == ms) ms = 60 * 60 * 24 * 365 * 1000;
|
||||
debug('max-age %d', ms);
|
||||
this._maxage = ms;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Emit error with `status`.
|
||||
*
|
||||
* @param {Number} status
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.error = function(status, err){
|
||||
var res = this.res;
|
||||
var msg = http.STATUS_CODES[status];
|
||||
err = err || new Error(msg);
|
||||
err.status = status;
|
||||
if (this.listeners('error').length) return this.emit('error', err);
|
||||
res.statusCode = err.status;
|
||||
res.end(msg);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the pathname is potentially malicious.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.isMalicious = function(){
|
||||
return !this._root && ~this.path.indexOf('..');
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the pathname ends with "/".
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.hasTrailingSlash = function(){
|
||||
return '/' == this.path[this.path.length - 1];
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the basename leads with ".".
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.hasLeadingDot = function(){
|
||||
return '.' == basename(this.path)[0];
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this is a conditional GET request.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.isConditionalGET = function(){
|
||||
return this.req.headers['if-none-match']
|
||||
|| this.req.headers['if-modified-since'];
|
||||
};
|
||||
|
||||
/**
|
||||
* Strip content-* header fields.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.removeContentHeaderFields = function(){
|
||||
var res = this.res;
|
||||
Object.keys(res._headers).forEach(function(field){
|
||||
if (0 == field.indexOf('content')) {
|
||||
res.removeHeader(field);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Respond with 304 not modified.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.notModified = function(){
|
||||
var res = this.res;
|
||||
debug('not modified');
|
||||
this.removeContentHeaderFields();
|
||||
res.statusCode = 304;
|
||||
res.end();
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the request is cacheable, aka
|
||||
* responded with 2xx or 304 (see RFC 2616 section 14.2{5,6}).
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.isCachable = function(){
|
||||
var res = this.res;
|
||||
return (res.statusCode >= 200 && res.statusCode < 300) || 304 == res.statusCode;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle stat() error.
|
||||
*
|
||||
* @param {Error} err
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.onStatError = function(err){
|
||||
var notfound = ['ENOENT', 'ENAMETOOLONG', 'ENOTDIR'];
|
||||
if (~notfound.indexOf(err.code)) return this.error(404, err);
|
||||
this.error(500, err);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the cache is fresh.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.isFresh = function(){
|
||||
return fresh(this.req.headers, this.res._headers);
|
||||
};
|
||||
|
||||
/**
|
||||
* Redirect to `path`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.redirect = function(path){
|
||||
if (this.listeners('directory').length) return this.emit('directory');
|
||||
var res = this.res;
|
||||
path += '/';
|
||||
res.statusCode = 301;
|
||||
res.setHeader('Location', path);
|
||||
res.end('Redirecting to ' + utils.escape(path));
|
||||
};
|
||||
|
||||
/**
|
||||
* Pipe to `res.
|
||||
*
|
||||
* @param {Stream} res
|
||||
* @return {Stream} res
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.pipe = function(res){
|
||||
var self = this
|
||||
, args = arguments
|
||||
, path = this.path
|
||||
, root = this._root;
|
||||
|
||||
// references
|
||||
this.res = res;
|
||||
|
||||
// invalid request uri
|
||||
path = utils.decode(path);
|
||||
if (-1 == path) return this.error(400);
|
||||
|
||||
// null byte(s)
|
||||
if (~path.indexOf('\0')) return this.error(400);
|
||||
|
||||
// join / normalize from optional root dir
|
||||
if (root) path = normalize(join(this._root, path));
|
||||
|
||||
// ".." is malicious without "root"
|
||||
if (this.isMalicious()) return this.error(403);
|
||||
|
||||
// malicious path
|
||||
if (root && 0 != path.indexOf(root)) return this.error(403);
|
||||
|
||||
// hidden file support
|
||||
if (!this._hidden && this.hasLeadingDot()) return this.error(404);
|
||||
|
||||
// index file support
|
||||
if (this._index && this.hasTrailingSlash()) path += this._index;
|
||||
|
||||
debug('stat "%s"', path);
|
||||
fs.stat(path, function(err, stat){
|
||||
if (err) return self.onStatError(err);
|
||||
if (stat.isDirectory()) return self.redirect(self.path);
|
||||
self.send(path, stat);
|
||||
});
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Transfer `path`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.send = function(path, stat){
|
||||
var options = this.options;
|
||||
var len = stat.size;
|
||||
var res = this.res;
|
||||
var req = this.req;
|
||||
var ranges = req.headers.range;
|
||||
var offset = options.start || 0;
|
||||
|
||||
// set header fields
|
||||
this.setHeader(stat);
|
||||
|
||||
// set content-type
|
||||
this.type(path);
|
||||
|
||||
// conditional GET support
|
||||
if (this.isConditionalGET()
|
||||
&& this.isCachable()
|
||||
&& this.isFresh()) {
|
||||
return this.notModified();
|
||||
}
|
||||
|
||||
// adjust len to start/end options
|
||||
len = Math.max(0, len - offset);
|
||||
if (options.end !== undefined) {
|
||||
var bytes = options.end - offset + 1;
|
||||
if (len > bytes) len = bytes;
|
||||
}
|
||||
|
||||
// Range support
|
||||
if (ranges) {
|
||||
ranges = parseRange(len, ranges);
|
||||
|
||||
// unsatisfiable
|
||||
if (-1 == ranges) {
|
||||
res.setHeader('Content-Range', 'bytes */' + stat.size);
|
||||
return this.error(416);
|
||||
}
|
||||
|
||||
// valid (syntactically invalid ranges are treated as a regular response)
|
||||
if (-2 != ranges) {
|
||||
options.start = offset + ranges[0].start;
|
||||
options.end = offset + ranges[0].end;
|
||||
|
||||
// Content-Range
|
||||
res.statusCode = 206;
|
||||
res.setHeader('Content-Range', 'bytes '
|
||||
+ ranges[0].start
|
||||
+ '-'
|
||||
+ ranges[0].end
|
||||
+ '/'
|
||||
+ len);
|
||||
len = options.end - options.start + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// content-length
|
||||
res.setHeader('Content-Length', len);
|
||||
|
||||
// HEAD support
|
||||
if ('HEAD' == req.method) return res.end();
|
||||
|
||||
this.stream(path, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stream `path` to the response.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} options
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.stream = function(path, options){
|
||||
// TODO: this is all lame, refactor meeee
|
||||
var self = this;
|
||||
var res = this.res;
|
||||
var req = this.req;
|
||||
|
||||
// pipe
|
||||
var stream = fs.createReadStream(path, options);
|
||||
this.emit('stream', stream);
|
||||
stream.pipe(res);
|
||||
|
||||
// socket closed, done with the fd
|
||||
req.on('close', stream.destroy.bind(stream));
|
||||
|
||||
// error handling code-smell
|
||||
stream.on('error', function(err){
|
||||
// no hope in responding
|
||||
if (res._header) {
|
||||
console.error(err.stack);
|
||||
req.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
// 500
|
||||
err.status = 500;
|
||||
self.emit('error', err);
|
||||
});
|
||||
|
||||
// end
|
||||
stream.on('end', function(){
|
||||
self.emit('end');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Set content-type based on `path`
|
||||
* if it hasn't been explicitly set.
|
||||
*
|
||||
* @param {String} path
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.type = function(path){
|
||||
var res = this.res;
|
||||
if (res.getHeader('Content-Type')) return;
|
||||
var type = mime.lookup(path);
|
||||
var charset = mime.charsets.lookup(type);
|
||||
debug('content-type %s', type);
|
||||
res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : ''));
|
||||
};
|
||||
|
||||
/**
|
||||
* Set reaponse header fields, most
|
||||
* fields may be pre-defined.
|
||||
*
|
||||
* @param {Object} stat
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.setHeader = function(stat){
|
||||
var res = this.res;
|
||||
if (!res.getHeader('Accept-Ranges')) res.setHeader('Accept-Ranges', 'bytes');
|
||||
if (!res.getHeader('ETag')) res.setHeader('ETag', utils.etag(stat));
|
||||
if (!res.getHeader('Date')) res.setHeader('Date', new Date().toUTCString());
|
||||
if (!res.getHeader('Cache-Control')) res.setHeader('Cache-Control', 'public, max-age=' + (this._maxage / 1000));
|
||||
if (!res.getHeader('Last-Modified')) res.setHeader('Last-Modified', stat.mtime.toUTCString());
|
||||
};
|
||||
47
node_modules/send/lib/utils.js
generated
vendored
Normal file
47
node_modules/send/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
/**
|
||||
* Return an ETag in the form of `"<size>-<mtime>"`
|
||||
* from the given `stat`.
|
||||
*
|
||||
* @param {Object} stat
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.etag = function(stat) {
|
||||
return '"' + stat.size + '-' + Number(stat.mtime) + '"';
|
||||
};
|
||||
|
||||
/**
|
||||
* decodeURIComponent.
|
||||
*
|
||||
* Allows V8 to only deoptimize this fn instead of all
|
||||
* of send().
|
||||
*
|
||||
* @param {String} path
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.decode = function(path){
|
||||
try {
|
||||
return decodeURIComponent(path);
|
||||
} catch (err) {
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Escape the given string of `html`.
|
||||
*
|
||||
* @param {String} html
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.escape = function(html){
|
||||
return String(html)
|
||||
.replace(/&(?!\w+;)/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
};
|
||||
19
node_modules/send/node_modules/mime/LICENSE
generated
vendored
Normal file
19
node_modules/send/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
node_modules/send/node_modules/mime/README.md
generated
vendored
Normal file
63
node_modules/send/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.
|
||||
104
node_modules/send/node_modules/mime/mime.js
generated
vendored
Normal file
104
node_modules/send/node_modules/mime/mime.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
function Mime() {
|
||||
// Map of extension -> mime type
|
||||
this.types = Object.create(null);
|
||||
|
||||
// Map of mime type -> extension
|
||||
this.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
|
||||
*/
|
||||
Mime.prototype.define = function (map) {
|
||||
for (var type in map) {
|
||||
var exts = map[type];
|
||||
|
||||
for (var i = 0; i < exts.length; i++) {
|
||||
this.types[exts[i]] = type;
|
||||
}
|
||||
|
||||
// Default extension is the first one we encounter
|
||||
if (!this.extensions[type]) {
|
||||
this.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.
|
||||
*/
|
||||
Mime.prototype.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) {
|
||||
// Clean up whitespace/comments, and split into fields
|
||||
var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
|
||||
map[fields.shift()] = fields;
|
||||
});
|
||||
|
||||
this.define(map);
|
||||
};
|
||||
|
||||
/**
|
||||
* Lookup a mime type based on extension
|
||||
*/
|
||||
Mime.prototype.lookup = function(path, fallback) {
|
||||
var ext = path.replace(/.*[\.\/]/, '').toLowerCase();
|
||||
|
||||
return this.types[ext] || fallback || this.default_type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return file extension associated with a mime type
|
||||
*/
|
||||
Mime.prototype.extension = function(mimeType) {
|
||||
return this.extensions[mimeType];
|
||||
};
|
||||
|
||||
// Default instance
|
||||
var mime = new Mime();
|
||||
|
||||
// Load local copy of
|
||||
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
mime.load(path.join(__dirname, 'types/mime.types'));
|
||||
|
||||
// Load additional types from node.js community
|
||||
mime.load(path.join(__dirname, 'types/node.types'));
|
||||
|
||||
// Default type
|
||||
mime.default_type = mime.lookup('bin');
|
||||
|
||||
//
|
||||
// Additional API specific to the default instance
|
||||
//
|
||||
|
||||
mime.Mime = Mime;
|
||||
|
||||
/**
|
||||
* Lookup a charset based on mime type.
|
||||
*/
|
||||
mime.charsets = {
|
||||
lookup: function(mimeType, fallback) {
|
||||
// Assume text types are utf8
|
||||
return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = mime;
|
||||
88
node_modules/send/node_modules/mime/package.json
generated
vendored
Normal file
88
node_modules/send/node_modules/mime/package.json
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"mime@1.2.6",
|
||||
"C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\send"
|
||||
]
|
||||
],
|
||||
"_defaultsLoaded": true,
|
||||
"_engineSupported": true,
|
||||
"_from": "mime@1.2.6",
|
||||
"_id": "mime@1.2.6",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/send/mime",
|
||||
"_nodeVersion": "v0.6.14",
|
||||
"_npmUser": {
|
||||
"email": "benjamin@benjaminthomas.org",
|
||||
"name": "bentomas"
|
||||
},
|
||||
"_npmVersion": "1.1.12",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "mime",
|
||||
"raw": "mime@1.2.6",
|
||||
"rawSpec": "1.2.6",
|
||||
"scope": null,
|
||||
"spec": "1.2.6",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/send"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/mime/-/mime-1.2.6.tgz",
|
||||
"_shasum": "b1f86c768c025fa87b48075f1709f28aeaf20365",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "mime@1.2.6",
|
||||
"_where": "C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\send",
|
||||
"author": {
|
||||
"email": "robert@broofa.com",
|
||||
"name": "Robert Kieffer",
|
||||
"url": "http://github.com/broofa"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/broofa/node-mime/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"email": "benjamin@benjaminthomas.org",
|
||||
"name": "Benjamin Thomas",
|
||||
"url": "http://github.com/bentomas"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "A comprehensive library for mime-type mapping",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "b1f86c768c025fa87b48075f1709f28aeaf20365",
|
||||
"tarball": "http://registry.npmjs.org/mime/-/mime-1.2.6.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/broofa/node-mime#readme",
|
||||
"keywords": [
|
||||
"util",
|
||||
"mime"
|
||||
],
|
||||
"main": "mime.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "robert@broofa.com",
|
||||
"name": "broofa"
|
||||
},
|
||||
{
|
||||
"email": "benjamin@benjaminthomas.org",
|
||||
"name": "bentomas"
|
||||
}
|
||||
],
|
||||
"name": "mime",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/broofa/node-mime.git"
|
||||
},
|
||||
"version": "1.2.6"
|
||||
}
|
||||
55
node_modules/send/node_modules/mime/test.js
generated
vendored
Normal file
55
node_modules/send/node_modules/mime/test.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 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'));
|
||||
eq('text/event-stream', mime.lookup('text/event-stream'));
|
||||
eq('application/x-web-app-manifest+json', mime.lookup('text.webapp'));
|
||||
|
||||
//
|
||||
// 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
node_modules/send/node_modules/mime/types/mime.types
generated
vendored
Normal file
1510
node_modules/send/node_modules/mime/types/mime.types
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
65
node_modules/send/node_modules/mime/types/node.types
generated
vendored
Normal file
65
node_modules/send/node_modules/mime/types/node.types
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
# 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
|
||||
|
||||
# What: EventSource mime type
|
||||
# Why: mime type of Server-Sent Events stream
|
||||
# http://www.w3.org/TR/eventsource/#text-event-stream
|
||||
# Added by: francois2metz
|
||||
text/event-stream event-stream
|
||||
|
||||
# What: Mozilla App manifest mime type
|
||||
# Why: https://developer.mozilla.org/en/Apps/Manifest#Serving_manifests
|
||||
# Added by: ednapiranha
|
||||
application/x-web-app-manifest+json webapp
|
||||
|
||||
# What: Matroska Mime Types
|
||||
# Why: http://en.wikipedia.org/wiki/Matroska
|
||||
# Added by: aduncan88
|
||||
video/x-matroska mkv
|
||||
audio/x-matroska mka
|
||||
76
node_modules/send/package.json
generated
vendored
Normal file
76
node_modules/send/package.json
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"send@0.1.0",
|
||||
"C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\express"
|
||||
]
|
||||
],
|
||||
"_from": "send@0.1.0",
|
||||
"_id": "send@0.1.0",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/send",
|
||||
"_npmUser": {
|
||||
"email": "tj@vision-media.ca",
|
||||
"name": "tjholowaychuk"
|
||||
},
|
||||
"_npmVersion": "1.1.61",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "send",
|
||||
"raw": "send@0.1.0",
|
||||
"rawSpec": "0.1.0",
|
||||
"scope": null,
|
||||
"spec": "0.1.0",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/send/-/send-0.1.0.tgz",
|
||||
"_shasum": "cfb08ebd3cec9b7fc1a37d9ff9e875a971cf4640",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "send@0.1.0",
|
||||
"_where": "C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\express",
|
||||
"author": {
|
||||
"email": "tj@vision-media.ca",
|
||||
"name": "TJ Holowaychuk"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "*",
|
||||
"fresh": "0.1.0",
|
||||
"mime": "1.2.6",
|
||||
"range-parser": "0.0.4"
|
||||
},
|
||||
"description": "Better streaming static file server with Range and conditional-GET support",
|
||||
"devDependencies": {
|
||||
"connect": "2.x",
|
||||
"mocha": "*",
|
||||
"should": "*",
|
||||
"supertest": "0.0.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "cfb08ebd3cec9b7fc1a37d9ff9e875a971cf4640",
|
||||
"tarball": "http://registry.npmjs.org/send/-/send-0.1.0.tgz"
|
||||
},
|
||||
"keywords": [
|
||||
"static",
|
||||
"file",
|
||||
"server"
|
||||
],
|
||||
"main": "index",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "tj@vision-media.ca",
|
||||
"name": "tjholowaychuk"
|
||||
}
|
||||
],
|
||||
"name": "send",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "0.1.0"
|
||||
}
|
||||
Reference in New Issue
Block a user