Update Node http-server to 0.10.0

This commit is contained in:
Joshua Granick
2017-06-05 15:10:10 -07:00
parent dab605d892
commit 1683c0db93
243 changed files with 8993 additions and 7868 deletions

View File

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
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.

View File

@@ -0,0 +1,108 @@
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++) {
if (process.env.DEBUG_MIME && this.types[exts[i]]) {
console.warn((this._loading || "define()").replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' +
this.types[exts[i]] + ' to ' + type);
}
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) {
this._loading = 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);
this._loading = null;
};
/**
* 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) {
var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();
return this.extensions[type];
};
// Default instance
var mime = new Mime();
// Define built-in types
mime.define(require('./types.json'));
// 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\/|^application\/(javascript|json)/).test(mimeType) ? 'UTF-8' : fallback;
}
};
module.exports = mime;

View File

@@ -0,0 +1,98 @@
{
"_args": [
[
"mime@^1.2.11",
"/home/joshua/Development/Haxe/test/node_modules/ecstatic"
]
],
"_from": "mime@>=1.2.11 <2.0.0",
"_id": "mime@1.3.6",
"_inCache": true,
"_installable": true,
"_location": "/mime",
"_nodeVersion": "6.9.2",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/mime-1.3.6.tgz_1494565179088_0.4127067362423986"
},
"_npmUser": {
"email": "robert@broofa.com",
"name": "broofa"
},
"_npmVersion": "4.3.0",
"_phantomChildren": {},
"_requested": {
"name": "mime",
"raw": "mime@^1.2.11",
"rawSpec": "^1.2.11",
"scope": null,
"spec": ">=1.2.11 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/ecstatic"
],
"_resolved": "https://registry.npmjs.org/mime/-/mime-1.3.6.tgz",
"_shasum": "591d84d3653a6b0b4a3b9df8de5aa8108e72e5e0",
"_shrinkwrap": null,
"_spec": "mime@^1.2.11",
"_where": "/home/joshua/Development/Haxe/test/node_modules/ecstatic",
"author": {
"email": "robert@broofa.com",
"name": "Robert Kieffer",
"url": "http://github.com/broofa"
},
"bin": {
"mime": "cli.js"
},
"bugs": {
"url": "https://github.com/broofa/node-mime/issues"
},
"contributors": [
{
"name": "Benjamin Thomas",
"email": "benjamin@benjaminthomas.org",
"url": "http://github.com/bentomas"
}
],
"dependencies": {},
"description": "A comprehensive library for mime-type mapping",
"devDependencies": {
"mime-db": "^1.22.0"
},
"directories": {},
"dist": {
"shasum": "591d84d3653a6b0b4a3b9df8de5aa8108e72e5e0",
"tarball": "https://registry.npmjs.org/mime/-/mime-1.3.6.tgz"
},
"gitHead": "78aa9df74925ee629b9f2c35ec16b099189e9cef",
"homepage": "https://github.com/broofa/node-mime#readme",
"keywords": [
"mime",
"util"
],
"license": "MIT",
"main": "mime.js",
"maintainers": [
{
"name": "broofa",
"email": "robert@broofa.com"
},
{
"name": "bentomas",
"email": "benjamin@benjaminthomas.org"
}
],
"name": "mime",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/broofa/node-mime.git"
},
"scripts": {
"prepublish": "node build/build.js > types.json",
"test": "node build/test.js"
},
"version": "1.3.6"
}

File diff suppressed because one or more lines are too long