vulcan 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -80
- data/lib/vulcan/cli.rb +12 -33
- data/lib/vulcan/version.rb +1 -1
- data/server/bin/make +3 -1
- data/server/lib/spawner.js +4 -9
- data/server/node_modules/connect-form/node_modules/formidable/Readme.md +2 -13
- data/server/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js +7 -19
- data/server/node_modules/connect-form/node_modules/formidable/lib/multipart_parser.js +1 -12
- data/server/node_modules/connect-form/node_modules/formidable/package.json +1 -1
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +10 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +9 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +1 -1
- data/server/node_modules/cradle/lib/cradle.js +1 -0
- data/server/node_modules/cradle/node_modules/vows/LICENSE +20 -0
- data/server/node_modules/cradle/node_modules/vows/Makefile +7 -0
- data/server/node_modules/cradle/node_modules/vows/README.md +39 -0
- data/server/node_modules/cradle/node_modules/vows/bin/vows +515 -0
- data/server/node_modules/cradle/node_modules/vows/lib/assert/error.js +27 -0
- data/server/node_modules/cradle/node_modules/vows/lib/assert/macros.js +215 -0
- data/server/node_modules/cradle/node_modules/vows/lib/assert/utils.js +77 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows.js +193 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/console.js +131 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/context.js +55 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/file.js +29 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-foot.html +2 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-head.html +61 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-html.js +54 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-json.js +54 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-plain.js +38 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/extras.js +28 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/dot-matrix.js +67 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/json.js +16 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/silent.js +8 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/spec.js +44 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/watch.js +39 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/xunit.js +90 -0
- data/server/node_modules/cradle/node_modules/vows/lib/vows/suite.js +319 -0
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/LICENSE +20 -0
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/Makefile +4 -0
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/README.md +72 -0
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/lib/eyes.js +233 -0
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/package.json +14 -0
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/test/eyes-test.js +55 -0
- data/server/node_modules/cradle/node_modules/vows/package.json +14 -0
- data/server/node_modules/cradle/node_modules/vows/test/assert-test.js +135 -0
- data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/failing.js +18 -0
- data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/log.js +18 -0
- data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/passing.js +17 -0
- data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/stderr.js +18 -0
- data/server/node_modules/cradle/node_modules/vows/test/isolate-test.js +140 -0
- data/server/node_modules/cradle/node_modules/vows/test/testInherit.js +133 -0
- data/server/node_modules/cradle/node_modules/vows/test/vows-error-test.js +51 -0
- data/server/node_modules/cradle/node_modules/vows/test/vows-test.js +374 -0
- data/server/node_modules/cradle/package.json +3 -3
- data/server/node_modules/cradle/test/cache-test.js +7 -6
- data/server/node_modules/cradle/test/cradle-test.js +5 -4
- data/server/node_modules/cradle/test/response-test.js +6 -5
- data/server/node_modules/express/History.md +1 -53
- data/server/node_modules/express/Makefile +9 -3
- data/server/node_modules/express/Readme.md +1 -3
- data/server/node_modules/express/bin/express +66 -65
- data/server/node_modules/express/lib/express.js +1 -1
- data/server/node_modules/express/lib/request.js +9 -23
- data/server/node_modules/express/lib/response.js +2 -3
- data/server/node_modules/express/lib/utils.js +0 -13
- data/server/node_modules/express/lib/view.js +16 -19
- data/server/node_modules/express/lib/view/view.js +1 -2
- data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
- data/server/node_modules/express/node_modules/connect/lib/http.js +0 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js +31 -135
- data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +1 -5
- data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +2 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/static.js +21 -26
- data/server/node_modules/express/node_modules/connect/lib/middleware/staticCache.js +38 -91
- data/server/node_modules/express/node_modules/connect/lib/middleware/vhost.js +1 -1
- data/server/node_modules/express/node_modules/connect/lib/utils.js +4 -11
- data/server/node_modules/express/node_modules/connect/package.json +6 -7
- data/server/node_modules/express/node_modules/connect/test.js +31 -44
- data/server/node_modules/express/node_modules/mime/index.js +1 -0
- data/server/node_modules/express/node_modules/mime/mime.js +3 -3
- data/server/node_modules/express/node_modules/mime/{types/mime.types → mime.types} +0 -0
- data/server/node_modules/express/node_modules/mime/{types/node.types → node.types} +0 -17
- data/server/node_modules/express/node_modules/mime/package.json +10 -21
- data/server/node_modules/express/node_modules/mime/test.js +3 -2
- data/server/node_modules/express/node_modules/qs/History.md +0 -11
- data/server/node_modules/express/node_modules/qs/Makefile +3 -1
- data/server/node_modules/express/node_modules/qs/Readme.md +4 -2
- data/server/node_modules/express/node_modules/qs/lib/querystring.js +74 -100
- data/server/node_modules/express/node_modules/qs/package.json +2 -9
- data/server/node_modules/express/node_modules/qs/support/expresso/History.md +128 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/Makefile +53 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/Readme.md +61 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/bin/expresso +856 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/api.html +1080 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.html +377 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.md +290 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/lib/bar.js +4 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/lib/foo.js +16 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/package.json +12 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/test/assert.test.js +91 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/test/async.test.js +12 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/test/bar.test.js +13 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/test/foo.test.js +14 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/test/http.test.js +146 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
- data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
- data/server/node_modules/express/node_modules/qs/support/should/History.md +22 -0
- data/server/node_modules/express/node_modules/qs/support/should/Makefile +6 -0
- data/server/node_modules/express/node_modules/qs/support/should/Readme.md +248 -0
- data/server/node_modules/express/node_modules/qs/support/should/examples/runner.js +53 -0
- data/server/node_modules/express/node_modules/qs/support/should/index.js +2 -0
- data/server/node_modules/express/node_modules/qs/support/should/lib/eql.js +91 -0
- data/server/node_modules/express/node_modules/qs/support/should/lib/should.js +548 -0
- data/server/node_modules/express/node_modules/qs/support/should/package.json +8 -0
- data/server/node_modules/express/node_modules/qs/support/should/test/should.test.js +358 -0
- data/server/node_modules/express/node_modules/qs/test/{parse.js → parse.test.js} +2 -1
- data/server/node_modules/express/node_modules/qs/test/{stringify.js → stringify.test.js} +0 -0
- data/server/node_modules/express/package.json +8 -9
- data/server/node_modules/node-uuid/README.md +67 -166
- data/server/node_modules/node-uuid/package.json +3 -5
- data/server/node_modules/node-uuid/{benchmark → test}/benchmark-native.c +0 -0
- data/server/node_modules/node-uuid/test/benchmark.js +27 -0
- data/server/node_modules/node-uuid/test/test.html +0 -3
- data/server/node_modules/node-uuid/test/test.js +57 -214
- data/server/node_modules/node-uuid/uuid.js +56 -225
- data/server/node_modules/restler/README.md +7 -20
- data/server/node_modules/restler/bin/restler +1 -1
- data/server/node_modules/restler/lib/multipartform.js +8 -9
- data/server/node_modules/restler/lib/restler.js +22 -64
- data/server/node_modules/restler/package.json +2 -2
- data/server/node_modules/restler/test/restler.js +2 -22
- data/server/node_modules/restler/test/test_helper.js +1 -20
- data/server/package.json +10 -10
- data/server/web.js +7 -30
- metadata +96 -89
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/file/plain.txt +0 -1
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/js/no-filename.js +0 -3
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/Makefile +0 -14
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +0 -286
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/TODO +0 -3
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/benchmark/bench-multipart-parser.js +0 -70
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/post.js +0 -43
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/upload.js +0 -48
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/index.js +0 -1
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/file.js +0 -61
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +0 -377
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/index.js +0 -3
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js +0 -312
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js +0 -25
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js +0 -6
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js +0 -19
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt +0 -1
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt +0 -1
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md +0 -3
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js +0 -3
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +0 -21
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js +0 -72
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js +0 -89
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js +0 -80
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js +0 -104
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +0 -715
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +0 -50
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js +0 -45
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js +0 -72
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js +0 -2
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js +0 -63
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js +0 -47
- data/server/node_modules/express/node_modules/mkdirp/LICENSE +0 -21
- data/server/node_modules/express/node_modules/mkdirp/README.markdown +0 -21
- data/server/node_modules/express/node_modules/mkdirp/examples/pow.js +0 -6
- data/server/node_modules/express/node_modules/mkdirp/examples/pow.js.orig +0 -6
- data/server/node_modules/express/node_modules/mkdirp/examples/pow.js.rej +0 -19
- data/server/node_modules/express/node_modules/mkdirp/index.js +0 -20
- data/server/node_modules/express/node_modules/mkdirp/package.json +0 -23
- data/server/node_modules/express/node_modules/mkdirp/test/mkdirp.js +0 -28
- data/server/node_modules/express/node_modules/mkdirp/test/race.js +0 -41
- data/server/node_modules/express/node_modules/mkdirp/test/rel.js +0 -32
- data/server/node_modules/express/node_modules/qs/test/mocha.opts +0 -2
- data/server/node_modules/express/testing/foo/app.js +0 -35
- data/server/node_modules/express/testing/foo/package.json +0 -9
- data/server/node_modules/express/testing/foo/public/stylesheets/style.css +0 -8
- data/server/node_modules/express/testing/foo/routes/index.js +0 -10
- data/server/node_modules/express/testing/foo/views/index.jade +0 -2
- data/server/node_modules/express/testing/foo/views/layout.jade +0 -6
- data/server/node_modules/express/testing/index.js +0 -43
- data/server/node_modules/express/testing/public/test.txt +0 -2971
- data/server/node_modules/express/testing/views/page.html +0 -1
- data/server/node_modules/express/testing/views/page.jade +0 -3
- data/server/node_modules/express/testing/views/test.md +0 -1
- data/server/node_modules/express/testing/views/user/index.jade +0 -1
- data/server/node_modules/express/testing/views/user/list.jade +0 -1
- data/server/node_modules/node-uuid/benchmark/README.md +0 -53
- data/server/node_modules/node-uuid/benchmark/bench.gnu +0 -174
- data/server/node_modules/node-uuid/benchmark/bench.sh +0 -34
- data/server/node_modules/node-uuid/benchmark/benchmark.js +0 -84
- data/server/node_modules/node-uuid/test/benchmark-native +0 -0
- data/server/node_modules/node-uuid/test/compare_v1.js +0 -63
@@ -43,11 +43,7 @@ module.exports = function limit(bytes){
|
|
43
43
|
req._limit = true;
|
44
44
|
|
45
45
|
// limit by content-length
|
46
|
-
if (len && len > bytes)
|
47
|
-
res.statusCode = 413;
|
48
|
-
res.end('Request Entity Too Large');
|
49
|
-
return;
|
50
|
-
}
|
46
|
+
if (len && len > bytes) deny();
|
51
47
|
|
52
48
|
// limit
|
53
49
|
req.on('data', function(chunk){
|
@@ -55,10 +55,10 @@ function defaultFingerprint(req) {
|
|
55
55
|
};
|
56
56
|
|
57
57
|
/**
|
58
|
-
* Paths to ignore.
|
58
|
+
* Paths to ignore, defaulting to `/favicon.ico`.
|
59
59
|
*/
|
60
60
|
|
61
|
-
exports.ignore = [];
|
61
|
+
exports.ignore = ['/favicon.ico'];
|
62
62
|
|
63
63
|
/**
|
64
64
|
* Setup session store with the given `options`.
|
@@ -39,7 +39,6 @@ var fs = require('fs')
|
|
39
39
|
*
|
40
40
|
* - `maxAge` Browser cache maxAge in milliseconds. defaults to 0
|
41
41
|
* - `hidden` Allow transfer of hidden files. defaults to false
|
42
|
-
* - `redirect` Redirect to trailing "/" when the pathname is a dir
|
43
42
|
*
|
44
43
|
* @param {String} root
|
45
44
|
* @param {Object} options
|
@@ -102,7 +101,6 @@ var send = exports.send = function(req, res, next, options){
|
|
102
101
|
, head = 'HEAD' == req.method
|
103
102
|
, get = 'GET' == req.method
|
104
103
|
, root = options.root ? normalize(options.root) : null
|
105
|
-
, redirect = false === options.redirect ? false : true
|
106
104
|
, getOnly = options.getOnly
|
107
105
|
, fn = options.callback
|
108
106
|
, hidden = options.hidden
|
@@ -134,7 +132,7 @@ var send = exports.send = function(req, res, next, options){
|
|
134
132
|
: utils.forbidden(res);
|
135
133
|
|
136
134
|
// index.html support
|
137
|
-
if (
|
135
|
+
if ('/' == path[path.length - 1]) path += 'index.html';
|
138
136
|
|
139
137
|
// "hidden" file
|
140
138
|
if (!hidden && '.' == basename(path)[0]) return next();
|
@@ -151,34 +149,13 @@ var send = exports.send = function(req, res, next, options){
|
|
151
149
|
: next(err);
|
152
150
|
// redirect directory in case index.html is present
|
153
151
|
} else if (stat.isDirectory()) {
|
154
|
-
if (!redirect) return next();
|
155
152
|
res.statusCode = 301;
|
156
153
|
res.setHeader('Location', url.pathname + '/');
|
157
154
|
res.end('Redirecting to ' + url.pathname + '/');
|
158
155
|
return;
|
159
156
|
}
|
160
157
|
|
161
|
-
// header fields
|
162
|
-
if (!res.getHeader('Date')) res.setHeader('Date', new Date().toUTCString());
|
163
|
-
if (!res.getHeader('Cache-Control')) res.setHeader('Cache-Control', 'public, max-age=' + (maxAge / 1000));
|
164
|
-
if (!res.getHeader('Last-Modified')) res.setHeader('Last-Modified', stat.mtime.toUTCString());
|
165
|
-
if (!res.getHeader('ETag')) res.setHeader('ETag', utils.etag(stat));
|
166
|
-
if (!res.getHeader('content-type')) {
|
167
|
-
var charset = mime.charsets.lookup(type);
|
168
|
-
res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : ''));
|
169
|
-
}
|
170
|
-
res.setHeader('Accept-Ranges', 'bytes');
|
171
|
-
|
172
|
-
// conditional GET support
|
173
|
-
if (utils.conditionalGET(req)) {
|
174
|
-
if (!utils.modified(req, res)) {
|
175
|
-
req.emit('static');
|
176
|
-
return utils.notModified(res);
|
177
|
-
}
|
178
|
-
}
|
179
|
-
|
180
158
|
var opts = {};
|
181
|
-
var chunkSize = stat.size;
|
182
159
|
|
183
160
|
// we have a Range request
|
184
161
|
if (ranges) {
|
@@ -189,7 +166,6 @@ var send = exports.send = function(req, res, next, options){
|
|
189
166
|
// TODO: multiple support
|
190
167
|
opts.start = ranges[0].start;
|
191
168
|
opts.end = ranges[0].end;
|
192
|
-
chunkSize = opts.end - opts.start + 1;
|
193
169
|
res.statusCode = 206;
|
194
170
|
res.setHeader('Content-Range', 'bytes '
|
195
171
|
+ opts.start
|
@@ -203,9 +179,27 @@ var send = exports.send = function(req, res, next, options){
|
|
203
179
|
? fn(new Error('Requested Range Not Satisfiable'))
|
204
180
|
: invalidRange(res);
|
205
181
|
}
|
182
|
+
// stream the entire file
|
183
|
+
} else {
|
184
|
+
res.setHeader('Content-Length', stat.size);
|
185
|
+
if (!res.getHeader('Cache-Control')) res.setHeader('Cache-Control', 'public, max-age=' + (maxAge / 1000));
|
186
|
+
if (!res.getHeader('Last-Modified')) res.setHeader('Last-Modified', stat.mtime.toUTCString());
|
187
|
+
if (!res.getHeader('ETag')) res.setHeader('ETag', utils.etag(stat));
|
188
|
+
|
189
|
+
// conditional GET support
|
190
|
+
if (utils.conditionalGET(req)) {
|
191
|
+
if (!utils.modified(req, res)) {
|
192
|
+
return utils.notModified(res);
|
193
|
+
}
|
194
|
+
}
|
206
195
|
}
|
207
196
|
|
208
|
-
|
197
|
+
// header fields
|
198
|
+
if (!res.getHeader('content-type')) {
|
199
|
+
var charset = mime.charsets.lookup(type);
|
200
|
+
res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : ''));
|
201
|
+
}
|
202
|
+
res.setHeader('Accept-Ranges', 'bytes');
|
209
203
|
|
210
204
|
// transfer
|
211
205
|
if (head) return res.end();
|
@@ -219,6 +213,7 @@ var send = exports.send = function(req, res, next, options){
|
|
219
213
|
if (fn) {
|
220
214
|
function callback(err) { done || fn(err); done = true }
|
221
215
|
req.on('close', callback);
|
216
|
+
req.socket.on('error', callback);
|
222
217
|
stream.on('end', callback);
|
223
218
|
}
|
224
219
|
});
|
@@ -10,7 +10,6 @@
|
|
10
10
|
*/
|
11
11
|
|
12
12
|
var http = require('http')
|
13
|
-
, utils = require('../utils')
|
14
13
|
, Cache = require('../cache')
|
15
14
|
, url = require('url')
|
16
15
|
, fs = require('fs');
|
@@ -34,15 +33,17 @@ var http = require('http')
|
|
34
33
|
*
|
35
34
|
* Benchmarks:
|
36
35
|
*
|
37
|
-
*
|
38
|
-
*
|
39
|
-
*
|
36
|
+
* static(): 2700 rps
|
37
|
+
* node-static: 5300 rps
|
38
|
+
* static() + staticCache(): 7500 rps
|
40
39
|
*
|
41
40
|
* Options:
|
42
41
|
*
|
43
42
|
* - `maxObjects` max cache objects [128]
|
44
43
|
* - `maxLength` max cache object length 256kb
|
45
44
|
*
|
45
|
+
* TODO: refactore to accept data stores (redis etc)
|
46
|
+
*
|
46
47
|
* @param {Type} name
|
47
48
|
* @return {Type}
|
48
49
|
* @api public
|
@@ -55,82 +56,16 @@ module.exports = function staticCache(options){
|
|
55
56
|
|
56
57
|
return function staticCache(req, res, next){
|
57
58
|
var path = url.parse(req.url).pathname
|
58
|
-
, ranges = req.headers.range
|
59
59
|
, hit = cache.get(path)
|
60
|
-
,
|
61
|
-
,
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
, contentLength = headers['content-length']
|
70
|
-
, hit;
|
71
|
-
|
72
|
-
// ignore larger files
|
73
|
-
if (!contentLength || contentLength > maxlen) return;
|
74
|
-
|
75
|
-
// dont cache items we shouldn't be
|
76
|
-
if ( cc['no-cache']
|
77
|
-
|| cc['no-store']
|
78
|
-
|| cc['private']
|
79
|
-
|| cc['must-revalidate']) return;
|
80
|
-
|
81
|
-
// if already in cache then validate
|
82
|
-
if (hit = cache.get(path)){
|
83
|
-
if (headers.etag == hit[0].etag) {
|
84
|
-
hit[0].date = new Date;
|
85
|
-
return;
|
86
|
-
} else {
|
87
|
-
cache.remove(path);
|
88
|
-
}
|
89
|
-
}
|
90
|
-
|
91
|
-
// validation notifiactions don't contain a steam
|
92
|
-
if (null == stream) return;
|
93
|
-
|
94
|
-
// add the cache object
|
95
|
-
var arr = cache.add(path);
|
96
|
-
arr.push(headers);
|
97
|
-
|
98
|
-
// store the chunks
|
99
|
-
stream.on('data', function(chunk){
|
100
|
-
arr.push(chunk);
|
101
|
-
});
|
102
|
-
|
103
|
-
// flag it as complete
|
104
|
-
stream.on('end', function(){
|
105
|
-
arr.complete = true;
|
106
|
-
});
|
107
|
-
});
|
108
|
-
|
109
|
-
// cache hit, doesnt support range requests
|
110
|
-
if (hit && hit.complete && !ranges) {
|
111
|
-
header = utils.merge({}, hit[0]);
|
112
|
-
header.Age = age = (new Date - new Date(header.date)) / 1000 | 0;
|
113
|
-
header.date = new Date().toUTCString();
|
114
|
-
|
115
|
-
// parse cache-controls
|
116
|
-
hitCC = utils.parseCacheControl(header['cache-control'] || '');
|
117
|
-
uaCC = utils.parseCacheControl(req.headers['cache-control'] || '');
|
118
|
-
|
119
|
-
// check if we must revalidate(bypass)
|
120
|
-
if (hitCC['no-cache'] || uaCC['no-cache']) return next();
|
121
|
-
|
122
|
-
// check freshness of entity
|
123
|
-
if (isStale(hitCC, age) || isStale(uaCC, age)) return next();
|
124
|
-
|
125
|
-
// conditional GET support
|
126
|
-
if (utils.conditionalGET(req)) {
|
127
|
-
if (!utils.modified(req, res, header)) {
|
128
|
-
header['content-length'] = 0;
|
129
|
-
res.writeHead(304, header);
|
130
|
-
return res.end();
|
131
|
-
}
|
132
|
-
}
|
133
|
-
|
60
|
+
, cc = req.headers['cache-control']
|
61
|
+
, header;
|
62
|
+
|
63
|
+
// cache hit
|
64
|
+
if (hit && hit.complete) {
|
65
|
+
// TODO: finish meeee... http caching... throttling etc
|
66
|
+
header = hit[0];
|
67
|
+
header.Age = (new Date - hit.createdAt) / 1000 | 0;
|
68
|
+
|
134
69
|
// HEAD support
|
135
70
|
if ('HEAD' == req.method) {
|
136
71
|
header['content-length'] = 0;
|
@@ -157,19 +92,31 @@ module.exports = function staticCache(options){
|
|
157
92
|
return write(1);
|
158
93
|
}
|
159
94
|
|
95
|
+
// cache static
|
96
|
+
req.on('static', function(stream){
|
97
|
+
// ignore larger files
|
98
|
+
var contentLength = res._headers['content-length'];
|
99
|
+
if (!contentLength || contentLength > maxlen) return;
|
100
|
+
|
101
|
+
// exists
|
102
|
+
if (cache.get(path)) return;
|
103
|
+
|
104
|
+
// add the cache object
|
105
|
+
var arr = cache.add(path);
|
106
|
+
arr.push(res._headers);
|
107
|
+
|
108
|
+
// store the chunks
|
109
|
+
stream.on('data', function(chunk){
|
110
|
+
arr.push(chunk);
|
111
|
+
});
|
112
|
+
|
113
|
+
// flag it as complete
|
114
|
+
stream.on('end', function(){
|
115
|
+
arr.complete = true;
|
116
|
+
});
|
117
|
+
});
|
118
|
+
|
160
119
|
next();
|
161
120
|
}
|
162
121
|
};
|
163
122
|
|
164
|
-
/**
|
165
|
-
* Check if cache item is stale
|
166
|
-
*
|
167
|
-
* @param {Object} cc
|
168
|
-
* @param {Number} age
|
169
|
-
* @return {Boolean}
|
170
|
-
* @api private
|
171
|
-
*/
|
172
|
-
|
173
|
-
function isStale(cc, age) {
|
174
|
-
return cc['max-age'] && cc['max-age'] <= age;
|
175
|
-
}
|
@@ -36,7 +36,7 @@ module.exports = function vhost(hostname, server){
|
|
36
36
|
var host = req.headers.host.split(':')[0];
|
37
37
|
if (req.subdomains = regexp.exec(host)) {
|
38
38
|
req.subdomains = req.subdomains[0].split('.').slice(0, -1);
|
39
|
-
server.emit("request", req, res);
|
39
|
+
server.emit("request", req, res, next);
|
40
40
|
} else {
|
41
41
|
next();
|
42
42
|
}
|
@@ -403,21 +403,14 @@ exports.parseRange = function(size, str){
|
|
403
403
|
*/
|
404
404
|
|
405
405
|
exports.parseCacheControl = function(str){
|
406
|
-
var
|
406
|
+
var parts = str.split('=')
|
407
|
+
, key = parts.shift()
|
408
|
+
, val = parseInt(parts.shift(), 10)
|
407
409
|
, obj = {};
|
408
|
-
|
409
|
-
for(var i = 0, len = directives.length; i < len; i++) {
|
410
|
-
var parts = directives[i].split('=')
|
411
|
-
, key = parts.shift().trim()
|
412
|
-
, val = parseInt(parts.shift(), 10);
|
413
|
-
|
414
|
-
obj[key] = isNaN(val) ? true : val;
|
415
|
-
}
|
416
|
-
|
410
|
+
obj[key] = isNaN(val) ? true : val;
|
417
411
|
return obj;
|
418
412
|
};
|
419
413
|
|
420
|
-
|
421
414
|
/**
|
422
415
|
* Convert array-like object to an `Array`.
|
423
416
|
*
|
@@ -1,25 +1,24 @@
|
|
1
1
|
{
|
2
2
|
"name": "connect",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.7.1",
|
4
4
|
"description": "High performance middleware framework",
|
5
5
|
"keywords": ["framework", "web", "middleware", "connect", "rack"],
|
6
6
|
"repository": "git://github.com/senchalabs/connect.git",
|
7
7
|
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",
|
8
8
|
"repository": "git://github.com/senchalabs/connect",
|
9
9
|
"dependencies": {
|
10
|
-
"qs": ">= 0.
|
11
|
-
"mime": ">= 0.0.1"
|
12
|
-
"formidable": "1.0.x"
|
10
|
+
"qs": ">= 0.3.1",
|
11
|
+
"mime": ">= 0.0.1"
|
13
12
|
},
|
14
13
|
"devDependencies": {
|
15
|
-
"expresso": "0.
|
14
|
+
"expresso": "0.7.6",
|
16
15
|
"koala": "0.1.2",
|
17
16
|
"less": "1.1.1",
|
18
17
|
"sass": "0.5.0",
|
19
18
|
"markdown": "0.2.1",
|
20
19
|
"ejs": "0.4.3",
|
21
|
-
"should": "0.
|
20
|
+
"should": "0.2.1"
|
22
21
|
},
|
23
22
|
"main": "index",
|
24
|
-
"engines": { "node": ">= 0.4.1 < 0.
|
23
|
+
"engines": { "node": ">= 0.4.1 < 0.5.0" }
|
25
24
|
}
|
@@ -1,52 +1,39 @@
|
|
1
1
|
|
2
|
+
/**
|
3
|
+
* Module dependencies.
|
4
|
+
*/
|
5
|
+
|
2
6
|
var connect = require('./')
|
7
|
+
, utils = connect.utils
|
3
8
|
, http = require('http')
|
4
|
-
,
|
9
|
+
, fs = require('fs');
|
5
10
|
|
6
|
-
var app = connect();
|
7
|
-
app.use(connect.cookieParser('fucj'));
|
8
|
-
app.use(connect.session({store:new RedisStore}));
|
9
|
-
app.use(function(req, res, next){
|
10
|
-
req.session.views = (req.session.views || 0) + 1;
|
11
|
-
res.writeHead(200, {"Content-Type": "text/plain"});
|
12
|
-
res.end("You've viewed this page "+req.session.views+" times.");
|
13
|
-
})
|
14
11
|
|
15
|
-
|
12
|
+
connect()
|
13
|
+
.use(connect.cookieParser())
|
14
|
+
.use(connect.session({ secret: 'hey' }))
|
15
|
+
.use(function(req, res, next){
|
16
|
+
if ('/foo' == req.url) {
|
17
|
+
req.session.foo = 'bar';
|
18
|
+
}
|
19
|
+
res.end('hello\n')
|
20
|
+
})
|
21
|
+
.listen(3000)
|
16
22
|
|
23
|
+
// Connect: 2296
|
24
|
+
// Connect+LRU: 4900
|
25
|
+
// node-static: 3865
|
17
26
|
|
18
|
-
//
|
19
|
-
|
20
|
-
//
|
21
|
-
//
|
22
|
-
//
|
23
|
-
|
24
|
-
//
|
25
|
-
//
|
26
|
-
// }, 2000, this);
|
27
|
-
// };
|
28
|
-
//
|
29
|
-
// http.createServer(connect()
|
30
|
-
// .use(connect.logger('dev'))
|
31
|
-
// .use(connect.cookieParser('keyboard cat'))
|
32
|
-
// .use(connect.session({ store: new RedisStore }))
|
33
|
-
// .use(function(req, res, next){
|
34
|
-
// var sess = req.session;
|
35
|
-
// switch (req.url) {
|
36
|
-
// case '/foo.js':
|
37
|
-
// console.log('%s foo.js sid', sess.id);
|
38
|
-
// RedisStore.prototype.set = set;
|
39
|
-
// res.end('data');
|
40
|
-
// break;
|
41
|
-
// default:
|
42
|
-
// console.log('%s html sid', sess.id);
|
43
|
-
// RedisStore.prototype.set = slow;
|
44
|
-
// res.setHeader('Content-Type', 'html');
|
45
|
-
// res.write('<html><head><script src="/foo.js"></script></head><body>');
|
46
|
-
// setTimeout(function(){
|
47
|
-
// res.end('</body></html>');
|
48
|
-
// }, 1000);
|
49
|
-
// }
|
50
|
-
// })).listen(3000);
|
27
|
+
// ab -n 5000 -c 50 -k http://local/Readme.md
|
28
|
+
|
29
|
+
// 472k
|
30
|
+
// node-static: 1651rps
|
31
|
+
// connect: 581rps
|
32
|
+
|
33
|
+
// var static = require('node-static')
|
34
|
+
// , file = new static.Server(__dirname);
|
51
35
|
//
|
52
|
-
//
|
36
|
+
// var send = connect.static(__dirname);
|
37
|
+
// http.createServer(function(req, res){
|
38
|
+
// file.serve(req, res);
|
39
|
+
// }).listen(3000);
|