This commit is contained in:
arnaucode
2017-02-03 08:56:51 +01:00
parent c4b7414770
commit 112745d6fa
1585 changed files with 450241 additions and 0 deletions

3
www/node_modules/http-server/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
node_modules/*
!node_modules/node-static
npm-debug.log

22
www/node_modules/http-server/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,22 @@
sudo: false
language: node_js
node_js:
- "0.10"
- "0.12"
- "4.1"
before_install:
- travis_retry npm install -g npm@2.14.5
- travis_retry npm install
script:
- npm test
matrix:
allow_failures:
- node_js: "0.10"
notifications:
email:
- travis@nodejitsu.com
irc: "irc.freenode.org#nodejitsu"

20
www/node_modules/http-server/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright (c) 2011 Charlie Robbins, Marak Squires, and the Contributors.
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.

69
www/node_modules/http-server/README.md generated vendored Normal file
View File

@@ -0,0 +1,69 @@
# http-server: a command-line http server
`http-server` is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.
![](https://github.com/nodeapps/http-server/raw/master/screenshots/public.png)
# Installing globally:
Installation via `npm`:
npm install http-server -g
This will install `http-server` globally so that it may be run from the command line.
## Usage:
http-server [path] [options]
`[path]` defaults to `./public` if the folder exists, and `./` otherwise.
# Installing as a node app
mkdir myapp
cd myapp/
jitsu install http-server
*If you do not have `jitsu` installed you can install it via `npm install jitsu -g`*
## Usage
### Starting http-server locally
node bin/http-server
*Now you can visit http://localhost:8080 to view your server*
## Available Options:
`-p` Port to use (defaults to 8080)
`-a` Address to use (defaults to 0.0.0.0)
`-d` Show directory listings (defaults to 'True')
`-i` Display autoIndex (defaults to 'True')
`-e` or `--ext` Default file extension if none supplied (defaults to 'html')
`-s` or `--silent` Suppress log messages from output
`--cors` Enable CORS via the `Access-Control-Allow-Origin` header
`-o` Open browser window after starting the server
`-c` Set cache time (in seconds) for cache-control max-age header, e.g. -c10 for 10 seconds (defaults to '3600'). To disable caching, use -c-1.
`-U` or `--utc` Use UTC time format in log messages.
`-P` or `--proxy` Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com
`-S` or `--ssl` Enable https.
`-C` or `--cert` Path to ssl cert file (default: cert.pem).
`-K` or `--key` Path to ssl key file (default: key.pem).
`-r` or `--robots` Provide a /robots.txt (whose content defaults to 'User-agent: *\nDisallow: /')
`-h` or `--help` Print this list and exit.

174
www/node_modules/http-server/bin/http-server generated vendored Executable file
View File

@@ -0,0 +1,174 @@
#!/usr/bin/env node
'use strict';
var colors = require('colors'),
os = require('os'),
httpServer = require('../lib/http-server'),
portfinder = require('portfinder'),
opener = require('opener'),
argv = require('optimist')
.boolean('cors')
.argv;
var ifaces = os.networkInterfaces();
if (argv.h || argv.help) {
console.log([
'usage: http-server [path] [options]',
'',
'options:',
' -p Port to use [8080]',
' -a Address to use [0.0.0.0]',
' -d Show directory listings [true]',
' -i Display autoIndex [true]',
' -e --ext Default file extension if none supplied [none]',
' -s --silent Suppress log messages from output',
' --cors[=headers] Enable CORS via the "Access-Control-Allow-Origin" header',
' Optionally provide CORS headers list separated by commas',
' -o [path] Open browser window after starting the server',
' -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.',
' To disable caching, use -c-1.',
' -U --utc Use UTC time format in log messages.',
'',
' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com',
'',
' -S --ssl Enable https.',
' -C --cert Path to ssl cert file (default: cert.pem).',
' -K --key Path to ssl key file (default: key.pem).',
'',
' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]',
' -h --help Print this list and exit.'
].join('\n'));
process.exit();
}
var port = argv.p || parseInt(process.env.PORT, 10),
host = argv.a || '0.0.0.0',
ssl = !!argv.S || !!argv.ssl,
proxy = argv.P || argv.proxy,
utc = argv.U || argv.utc,
logger;
if (!argv.s && !argv.silent) {
logger = {
info: console.log,
request: function (req, res, error) {
var date = utc ? new Date().toUTCString() : new Date();
if (error) {
logger.info(
'[%s] "%s %s" Error (%s): "%s"',
date, req.method.red, req.url.red,
error.status.toString().red, error.message.red
);
}
else {
logger.info(
'[%s] "%s %s" "%s"',
date, req.method.cyan, req.url.cyan,
req.headers['user-agent']
);
}
}
};
}
else if (colors) {
logger = {
info: function () {},
request: function () {}
};
}
if (!port) {
portfinder.basePort = 8080;
portfinder.getPort(function (err, port) {
if (err) { throw err; }
listen(port);
});
}
else {
listen(port);
}
function listen(port) {
var options = {
root: argv._[0],
cache: argv.c,
showDir: argv.d,
autoIndex: argv.i,
robots: argv.r || argv.robots,
ext: argv.e || argv.ext,
logFn: logger.request,
proxy: proxy
};
if (argv.cors) {
options.cors = true;
if (typeof argv.cors === 'string') {
options.corsHeaders = argv.cors;
}
}
if (ssl) {
options.https = {
cert: argv.C || argv.cert || 'cert.pem',
key: argv.K || argv.key || 'key.pem'
};
}
var server = httpServer.createServer(options);
server.listen(port, host, function () {
var canonicalHost = host === '0.0.0.0' ? '127.0.0.1' : host,
protocol = ssl ? 'https://' : 'http://';
logger.info(['Starting up http-server, serving '.yellow,
server.root.cyan,
ssl ? (' through'.yellow + ' https'.cyan) : '',
'\nAvailable on:'.yellow
].join(''));
if (argv.a && host !== '0.0.0.0') {
logger.info((' ' + protocol + canonicalHost + ':' + port.toString()).green);
}
else {
Object.keys(ifaces).forEach(function (dev) {
ifaces[dev].forEach(function (details) {
if (details.family === 'IPv4') {
logger.info((' ' + protocol + details.address + ':' + port.toString()).green);
}
});
});
}
if (typeof proxy === 'string') {
logger.info('Unhandled requests will be served from: ' + proxy);
}
logger.info('Hit CTRL-C to stop the server');
if (argv.o) {
opener(
protocol + '//' + canonicalHost + ':' + port,
{ command: argv.o !== true ? argv.o : null }
);
}
});
}
if (process.platform === 'win32') {
require('readline').createInterface({
input: process.stdin,
output: process.stdout
}).on('SIGINT', function () {
process.emit('SIGINT');
});
}
process.on('SIGINT', function () {
logger.info('http-server stopped.'.red);
process.exit();
});
process.on('SIGTERM', function () {
logger.info('http-server stopped.'.red);
process.exit();
});

139
www/node_modules/http-server/lib/http-server.js generated vendored Normal file
View File

@@ -0,0 +1,139 @@
'use strict';
var fs = require('fs'),
union = require('union'),
ecstatic = require('ecstatic'),
httpProxy = require('http-proxy'),
corser = require('corser');
//
// Remark: backwards compatibility for previous
// case convention of HTTP
//
exports.HttpServer = exports.HTTPServer = HttpServer;
/**
* Returns a new instance of HttpServer with the
* specified `options`.
*/
exports.createServer = function (options) {
return new HttpServer(options);
};
/**
* Constructor function for the HttpServer object
* which is responsible for serving static files along
* with other HTTP-related features.
*/
function HttpServer(options) {
options = options || {};
if (options.root) {
this.root = options.root;
}
else {
try {
fs.lstatSync('./public');
this.root = './public';
}
catch (err) {
this.root = './';
}
}
this.headers = options.headers || {};
this.cache = options.cache === undefined ? 3600 : options.cache; // in seconds.
this.showDir = options.showDir !== 'false';
this.autoIndex = options.autoIndex !== 'false';
this.contentType = options.contentType || 'application/octet-stream';
if (options.ext) {
this.ext = options.ext === true
? 'html'
: options.ext;
}
var before = options.before ? options.before.slice() : [];
before.push(function (req, res) {
if (options.logFn) {
options.logFn(req, res);
}
res.emit('next');
});
if (options.cors) {
this.headers['Access-Control-Allow-Origin'] = '*';
this.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Range';
if (options.corsHeaders) {
options.corsHeaders.split(/\s*,\s*/)
.forEach(function (h) { this.headers['Access-Control-Allow-Headers'] += ', ' + h; }, this);
}
before.push(corser.create(options.corsHeaders ? {
requestHeaders: this.headers['Access-Control-Allow-Headers'].split(/\s*,\s*/)
} : null));
}
if (options.robots) {
before.push(function (req, res) {
if (req.url === '/robots.txt') {
res.setHeader('Content-Type', 'text/plain');
var robots = options.robots === true
? 'User-agent: *\nDisallow: /'
: options.robots.replace(/\\n/, '\n');
return res.end(robots);
}
res.emit('next');
});
}
before.push(ecstatic({
root: this.root,
cache: this.cache,
showDir: this.showDir,
autoIndex: this.autoIndex,
defaultExt: this.ext,
contentType: this.contentType,
handleError: typeof options.proxy !== 'string'
}));
if (typeof options.proxy === 'string') {
var proxy = httpProxy.createProxyServer({});
before.push(function (req, res) {
proxy.web(req, res, {
target: options.proxy,
changeOrigin: true
});
});
}
var serverOptions = {
before: before,
headers: this.headers,
onError: function (err, req, res) {
if (options.logFn) {
options.logFn(req, res, err);
}
res.end();
}
};
if (options.https) {
serverOptions.https = options.https;
}
this.server = union.createServer(serverOptions);
}
HttpServer.prototype.listen = function () {
this.server.listen.apply(this.server, arguments);
};
HttpServer.prototype.close = function () {
return this.server.close();
};

145
www/node_modules/http-server/package.json generated vendored Normal file
View File

@@ -0,0 +1,145 @@
{
"_args": [
[
{
"raw": "http-server@0.9.0",
"scope": null,
"escapedName": "http-server",
"name": "http-server",
"rawSpec": "0.9.0",
"spec": "0.9.0",
"type": "version"
},
"/home/nau/MEGA/CODI/githubRepos/colspace/www"
]
],
"_from": "http-server@0.9.0",
"_id": "http-server@0.9.0",
"_inCache": true,
"_location": "/http-server",
"_nodeVersion": "4.2.2",
"_npmOperationalInternal": {
"host": "packages-6-west.internal.npmjs.com",
"tmp": "tmp/http-server-0.9.0.tgz_1455864708425_0.19514421350322664"
},
"_npmUser": {
"name": "indexzero",
"email": "charlie.robbins@gmail.com"
},
"_npmVersion": "3.7.1",
"_phantomChildren": {},
"_requested": {
"raw": "http-server@0.9.0",
"scope": null,
"escapedName": "http-server",
"name": "http-server",
"rawSpec": "0.9.0",
"spec": "0.9.0",
"type": "version"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/http-server/-/http-server-0.9.0.tgz",
"_shasum": "8f1b06bdc733618d4dc42831c7ba1aff4e06001a",
"_shrinkwrap": null,
"_spec": "http-server@0.9.0",
"_where": "/home/nau/MEGA/CODI/githubRepos/colspace/www",
"bin": {
"http-server": "./bin/http-server",
"hs": "./bin/http-server"
},
"bugs": {
"url": "https://github.com/nodeapps/http-server/issues"
},
"contributors": [
{
"name": "Charlie Robbins",
"email": "charlie.robbins@gmail.com"
},
{
"name": "Marak Squires",
"email": "marak.squires@gmail.com"
},
{
"name": "Charlie McConnell",
"email": "charlie@charlieistheman.com"
},
{
"name": "Joshua Holbrook",
"email": "josh.holbrook@gmail.com"
},
{
"name": "Maciej Małecki",
"email": "maciej.malecki@notimplemented.org"
},
{
"name": "Matthew Bergman",
"email": "mzbphoto@gmail.com"
},
{
"name": "brad dunbar",
"email": "dunbarb2@gmail.com"
},
{
"name": "Dominic Tarr"
},
{
"name": "Travis Person",
"email": "travis.person@gmail.com"
},
{
"name": "Jinkwon Lee",
"email": "master@bdyne.net"
}
],
"dependencies": {
"colors": "1.0.3",
"corser": "~2.0.0",
"ecstatic": "^1.4.0",
"http-proxy": "^1.8.1",
"opener": "~1.4.0",
"optimist": "0.6.x",
"portfinder": "0.4.x",
"union": "~0.4.3"
},
"description": "A simple zero-configuration command-line http server",
"devDependencies": {
"common-style": "^3.0.0",
"request": "2.49.x",
"vows": "0.7.x"
},
"directories": {},
"dist": {
"shasum": "8f1b06bdc733618d4dc42831c7ba1aff4e06001a",
"tarball": "https://registry.npmjs.org/http-server/-/http-server-0.9.0.tgz"
},
"gitHead": "1a8552c5e028bd5500027ee940111133927a4e94",
"homepage": "https://github.com/indexzero/http-server#readme",
"keywords": [
"cli",
"command"
],
"license": "MIT",
"main": "./lib/http-server",
"maintainers": [
{
"name": "indexzero",
"email": "charlie.robbins@gmail.com"
}
],
"name": "http-server",
"optionalDependencies": {},
"preferGlobal": "true",
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/indexzero/http-server.git"
},
"scripts": {
"pretest": "common bin/http-server lib/ test",
"start": "node ./bin/http-server",
"test": "vows --spec --isolate"
},
"version": "0.9.0"
}

10
www/node_modules/http-server/public/404.html generated vendored Normal file
View File

@@ -0,0 +1,10 @@
<html>
<head>
<title>404</title>
</head>
<body>
<h1>404</h1>
<p>Were you just making up filenames or what?</p>
</body>
</html>

BIN
www/node_modules/http-server/public/img/turtle.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

12
www/node_modules/http-server/public/index.html generated vendored Normal file
View File

@@ -0,0 +1,12 @@
<html>
<head>
<title>node.js http server</title>
</head>
<body>
<h1>Serving up static files like they were turtles strapped to rockets.</h1>
<img src="./img/turtle.png"/>
</body>
</html>

BIN
www/node_modules/http-server/screenshots/directory.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
www/node_modules/http-server/screenshots/public.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

BIN
www/node_modules/http-server/screenshots/start.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -0,0 +1,2 @@
I bet you can. I'm in your index.

2
www/node_modules/http-server/test/fixtures/root/file generated vendored Normal file
View File

@@ -0,0 +1,2 @@
hello, I know nodejitsu

158
www/node_modules/http-server/test/http-server-test.js generated vendored Normal file
View File

@@ -0,0 +1,158 @@
var assert = require('assert'),
path = require('path'),
fs = require('fs'),
vows = require('vows'),
request = require('request'),
httpServer = require('../lib/http-server');
var root = path.join(__dirname, 'fixtures', 'root');
vows.describe('http-server').addBatch({
'When http-server is listening on 8080': {
topic: function () {
var server = httpServer.createServer({
root: root,
robots: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true'
}
});
server.listen(8080);
this.callback(null, server);
},
'it should serve files from root directory': {
topic: function () {
request('http://127.0.0.1:8080/file', this.callback);
},
'status code should be 200': function (res) {
assert.equal(res.statusCode, 200);
},
'and file content': {
topic: function (res, body) {
var self = this;
fs.readFile(path.join(root, 'file'), 'utf8', function (err, data) {
self.callback(err, data, body);
});
},
'should match content of served file': function (err, file, body) {
assert.equal(body.trim(), file.trim());
}
}
},
'when requesting non-existent file': {
topic: function () {
request('http://127.0.0.1:8080/404', this.callback);
},
'status code should be 404': function (res) {
assert.equal(res.statusCode, 404);
}
},
'when requesting /': {
topic: function () {
request('http://127.0.0.1:8080/', this.callback);
},
'should respond with index': function (err, res, body) {
assert.equal(res.statusCode, 200);
assert.include(body, '/file');
assert.include(body, '/canYouSeeMe');
}
},
'when robots options is activated': {
topic: function () {
request('http://127.0.0.1:8080/', this.callback);
},
'should respond with status code 200 to /robots.txt': function (res) {
assert.equal(res.statusCode, 200);
}
},
'and options include custom set http-headers': {
topic: function () {
request('http://127.0.0.1:8080/', this.callback);
},
'should respond with headers set in options': function (err, res) {
assert.equal(res.headers['access-control-allow-origin'], '*');
assert.equal(res.headers['access-control-allow-credentials'], 'true');
}
},
'When http-server is proxying from 8081 to 8080': {
topic: function () {
var proxyServer = httpServer.createServer({
proxy: 'http://127.0.0.1:8080/',
root: path.join(__dirname, 'fixtures')
});
proxyServer.listen(8081);
this.callback(null, proxyServer);
},
'it should serve files from the proxy server root directory': {
topic: function () {
request('http://127.0.0.1:8081/root/file', this.callback);
},
'status code should be the enpoint code 200': function (res) {
assert.equal(res.statusCode, 200);
},
'and file content': {
topic: function (res, body) {
var self = this;
fs.readFile(path.join(root, 'file'), 'utf8', function (err, data) {
self.callback(err, data, body);
});
},
'should match content of the served file': function (err, file, body) {
assert.equal(body.trim(), file.trim());
}
}
},
'it should fallback to the proxied server': {
topic: function () {
request('http://127.0.0.1:8081/file', this.callback);
},
'status code should be the enpoint code 200': function (res) {
assert.equal(res.statusCode, 200);
},
'and file content': {
topic: function (res, body) {
var self = this;
fs.readFile(path.join(root, 'file'), 'utf8', function (err, data) {
self.callback(err, data, body);
});
},
'should match content of the proxied served file': function (err, file, body) {
assert.equal(body.trim(), file.trim());
}
}
}
}
},
'When cors is enabled': {
topic: function () {
var server = httpServer.createServer({
root: root,
cors: true,
corsHeaders: 'X-Test'
});
server.listen(8082);
this.callback(null, server);
},
'and given OPTIONS request': {
topic: function () {
request({
method: 'OPTIONS',
uri: 'http://127.0.0.1:8082/',
headers: {
'Access-Control-Request-Method': 'GET',
Origin: 'http://example.com',
'Access-Control-Request-Headers': 'Foobar'
}
}, this.callback);
},
'status code should be 204': function (err, res) {
assert.equal(res.statusCode, 204);
},
'response Access-Control-Allow-Headers should contain X-Test': function (err, res) {
assert.ok(res.headers['access-control-allow-headers'].split(/\s*,\s*/g).indexOf('X-Test') >= 0, 204);
}
}
}
}).export(module);