Permalink
Browse files

Updated to latest version of dependencies

  • Loading branch information...
1 parent f4265df commit c87069bfd0914367b0702b13c486cb1bd84fd86a @bbyars committed Jun 12, 2011
Showing with 16,676 additions and 614 deletions.
  1. +1 −1 server/deps/connect/lib/connect.js
  2. +1 −1 server/deps/connect/lib/http.js
  3. +43 −8 server/deps/connect/lib/middleware/basicAuth.js
  4. +1 −0 server/deps/connect/lib/middleware/bodyParser.js
  5. +10 −4 server/deps/connect/lib/middleware/errorHandler.js
  6. +14 −10 server/deps/connect/lib/middleware/limit.js
  7. +28 −14 server/deps/connect/lib/middleware/logger.js
  8. +112 −21 server/deps/connect/lib/middleware/router.js
  9. +42 −22 server/deps/connect/lib/middleware/session.js
  10. +27 −1 server/deps/connect/lib/middleware/session/session.js
  11. +22 −1 server/deps/connect/lib/middleware/session/store.js
  12. +39 −17 server/deps/connect/lib/middleware/static.js
  13. +30 −24 server/deps/connect/lib/patch.js
  14. +1 −1 server/deps/connect/lib/public/error.html
  15. +4 −60 server/deps/connect/lib/public/style.css
  16. +38 −0 server/deps/connect/lib/utils.js
  17. +9 −1 server/deps/connect/package.json
  18. +4 −14 server/deps/connect/test.js
  19. +3 −0 server/deps/ejs/.gitignore
  20. +3 −0 server/deps/ejs/.gitmodules
  21. +65 −0 server/deps/ejs/History.md
  22. +19 −0 server/deps/ejs/Makefile
  23. +142 −0 server/deps/ejs/Readme.md
  24. +14 −0 server/deps/ejs/benchmark.js
  25. +526 −0 server/deps/ejs/ejs.js
  26. +2 −0 server/deps/ejs/ejs.min.js
  27. +5 −0 server/deps/ejs/examples/client.html
  28. +7 −0 server/deps/ejs/examples/list.ejs
  29. +16 −0 server/deps/ejs/examples/list.js
  30. +2 −0 server/deps/ejs/index.js
  31. +248 −0 server/deps/ejs/lib/ejs.js
  32. +198 −0 server/deps/ejs/lib/filters.js
  33. +23 −0 server/deps/ejs/lib/utils.js
  34. +8 −0 server/deps/ejs/package.json
  35. +173 −0 server/deps/ejs/support/compile.js
  36. +3 −0 server/deps/ejs/support/expresso/.gitignore
  37. +3 −0 server/deps/ejs/support/expresso/.gitmodules
  38. +87 −0 server/deps/ejs/support/expresso/History.md
  39. +50 −0 server/deps/ejs/support/expresso/Makefile
  40. +39 −0 server/deps/ejs/support/expresso/Readme.md
  41. +775 −0 server/deps/ejs/support/expresso/bin/expresso
  42. +989 −0 server/deps/ejs/support/expresso/docs/api.html
  43. +380 −0 server/deps/ejs/support/expresso/docs/index.html
  44. +292 −0 server/deps/ejs/support/expresso/docs/index.md
  45. +3 −0 server/deps/ejs/support/expresso/docs/layout/foot.html
  46. +47 −0 server/deps/ejs/support/expresso/docs/layout/head.html
  47. +4 −0 server/deps/ejs/support/expresso/lib/bar.js
  48. +16 −0 server/deps/ejs/support/expresso/lib/foo.js
  49. +9 −0 server/deps/ejs/support/expresso/package.json
  50. +84 −0 server/deps/ejs/support/expresso/test/assert.test.js
  51. +6 −0 server/deps/ejs/support/expresso/test/async.test.js
  52. +12 −0 server/deps/ejs/support/expresso/test/bar.test.js
  53. +13 −0 server/deps/ejs/support/expresso/test/foo.test.js
  54. +76 −0 server/deps/ejs/support/expresso/test/http.test.js
  55. +245 −0 server/deps/ejs/test/ejs.test.js
  56. +164 −0 server/deps/express/History.md
  57. +6 −23 server/deps/express/Makefile
  58. +45 −1 server/deps/express/Readme.md
  59. +25 −56 server/deps/express/bin/express
  60. +13 −4 server/deps/express/lib/express.js
  61. +185 −114 server/deps/express/lib/http.js
  62. +15 −3 server/deps/express/lib/https.js
  63. +4 −3 server/deps/express/lib/request.js
  64. +63 −24 server/deps/express/lib/response.js
  65. +53 −0 server/deps/express/lib/router/collection.js
  66. +383 −0 server/deps/express/lib/router/index.js
  67. +70 −0 server/deps/express/lib/router/methods.js
  68. +85 −0 server/deps/express/lib/router/route.js
  69. +39 −59 server/deps/express/lib/utils.js
  70. +235 −101 server/deps/express/lib/view.js
  71. +21 −22 server/deps/express/lib/view/view.js
  72. +11 −0 server/deps/express/node_modules/connect/.npmignore
  73. +24 −0 server/deps/express/node_modules/connect/LICENSE
  74. +2 −0 server/deps/express/node_modules/connect/index.js
  75. +106 −0 server/deps/express/node_modules/connect/lib/connect.js
  76. +218 −0 server/deps/express/node_modules/connect/lib/http.js
  77. +47 −0 server/deps/express/node_modules/connect/lib/https.js
  78. +41 −0 server/deps/express/node_modules/connect/lib/index.js
  79. +93 −0 server/deps/express/node_modules/connect/lib/middleware/basicAuth.js
  80. +92 −0 server/deps/express/node_modules/connect/lib/middleware/bodyParser.js
  81. +163 −0 server/deps/express/node_modules/connect/lib/middleware/compiler.js
  82. +46 −0 server/deps/express/node_modules/connect/lib/middleware/cookieParser.js
  83. +100 −0 server/deps/express/node_modules/connect/lib/middleware/errorHandler.js
  84. +76 −0 server/deps/express/node_modules/connect/lib/middleware/favicon.js
  85. +78 −0 server/deps/express/node_modules/connect/lib/middleware/limit.js
  86. +169 −0 server/deps/express/node_modules/connect/lib/middleware/logger.js
  87. +38 −0 server/deps/express/node_modules/connect/lib/middleware/methodOverride.js
  88. +100 −0 server/deps/express/node_modules/connect/lib/middleware/profiler.js
  89. +34 −0 server/deps/express/node_modules/connect/lib/middleware/responseTime.js
  90. +379 −0 server/deps/express/node_modules/connect/lib/middleware/router.js
  91. +345 −0 server/deps/express/node_modules/connect/lib/middleware/session.js
  92. +126 −0 server/deps/express/node_modules/connect/lib/middleware/session/cookie.js
  93. +131 −0 server/deps/express/node_modules/connect/lib/middleware/session/memory.js
  94. +137 −0 server/deps/express/node_modules/connect/lib/middleware/session/session.js
  95. +59 −0 server/deps/express/node_modules/connect/lib/middleware/session/store.js
  96. +222 −0 server/deps/express/node_modules/connect/lib/middleware/static.js
  97. +44 −0 server/deps/express/node_modules/connect/lib/middleware/vhost.js
  98. +51 −0 server/deps/express/node_modules/connect/lib/patch.js
  99. +13 −0 server/deps/express/node_modules/connect/lib/public/error.html
  100. BIN server/deps/express/node_modules/connect/lib/public/favicon.ico
  101. +61 −0 server/deps/express/node_modules/connect/lib/public/style.css
  102. +405 −0 server/deps/express/node_modules/connect/lib/utils.js
  103. +22 −0 server/deps/express/node_modules/connect/package.json
  104. +13 −0 server/deps/express/node_modules/connect/test.js
  105. +19 −0 server/deps/express/node_modules/mime/LICENSE
  106. +54 −0 server/deps/express/node_modules/mime/README.md
  107. +1 −0 server/deps/express/node_modules/mime/index.js
  108. +89 −0 server/deps/express/node_modules/mime/mime.js
  109. +1,479 −0 server/deps/express/node_modules/mime/mime.types
  110. +7 −0 server/deps/express/node_modules/mime/node.types
  111. +11 −0 server/deps/express/node_modules/mime/package.json
  112. +74 −0 server/deps/express/node_modules/mime/test.js
  113. +6 −0 server/deps/express/node_modules/qs/.gitmodules
  114. +36 −0 server/deps/express/node_modules/qs/History.md
  115. +7 −0 server/deps/express/node_modules/qs/Makefile
  116. +38 −0 server/deps/express/node_modules/qs/Readme.md
  117. +32 −0 server/deps/express/node_modules/qs/benchmark.js
  118. +39 −0 server/deps/express/node_modules/qs/examples.js
  119. +2 −0 server/deps/express/node_modules/qs/index.js
  120. +123 −0 server/deps/express/node_modules/qs/lib/querystring.js
  121. +9 −0 server/deps/express/node_modules/qs/package.json
  122. +3 −0 server/deps/express/node_modules/qs/support/expresso/.gitignore
  123. +3 −0 server/deps/express/node_modules/qs/support/expresso/.gitmodules
  124. +128 −0 server/deps/express/node_modules/qs/support/expresso/History.md
  125. +53 −0 server/deps/express/node_modules/qs/support/expresso/Makefile
  126. +61 −0 server/deps/express/node_modules/qs/support/expresso/Readme.md
  127. +856 −0 server/deps/express/node_modules/qs/support/expresso/bin/expresso
  128. +1,080 −0 server/deps/express/node_modules/qs/support/expresso/docs/api.html
  129. +377 −0 server/deps/express/node_modules/qs/support/expresso/docs/index.html
  130. +290 −0 server/deps/express/node_modules/qs/support/expresso/docs/index.md
  131. +3 −0 server/deps/express/node_modules/qs/support/expresso/docs/layout/foot.html
  132. +42 −0 server/deps/express/node_modules/qs/support/expresso/docs/layout/head.html
  133. +4 −0 server/deps/express/node_modules/qs/support/expresso/lib/bar.js
  134. +16 −0 server/deps/express/node_modules/qs/support/expresso/lib/foo.js
  135. +12 −0 server/deps/express/node_modules/qs/support/expresso/package.json
  136. +91 −0 server/deps/express/node_modules/qs/support/expresso/test/assert.test.js
  137. +12 −0 server/deps/express/node_modules/qs/support/expresso/test/async.test.js
  138. +13 −0 server/deps/express/node_modules/qs/support/expresso/test/bar.test.js
  139. +14 −0 server/deps/express/node_modules/qs/support/expresso/test/foo.test.js
  140. +146 −0 server/deps/express/node_modules/qs/support/expresso/test/http.test.js
  141. +39 −0 server/deps/express/node_modules/qs/support/expresso/test/serial/async.test.js
  142. +48 −0 server/deps/express/node_modules/qs/support/expresso/test/serial/http.test.js
  143. +3 −0 server/deps/express/node_modules/qs/support/should/.gitmodules
  144. +22 −0 server/deps/express/node_modules/qs/support/should/History.md
  145. +6 −0 server/deps/express/node_modules/qs/support/should/Makefile
  146. +248 −0 server/deps/express/node_modules/qs/support/should/Readme.md
  147. +53 −0 server/deps/express/node_modules/qs/support/should/examples/runner.js
  148. +2 −0 server/deps/express/node_modules/qs/support/should/index.js
  149. +91 −0 server/deps/express/node_modules/qs/support/should/lib/eql.js
  150. +548 −0 server/deps/express/node_modules/qs/support/should/lib/should.js
  151. +8 −0 server/deps/express/node_modules/qs/support/should/package.json
  152. +358 −0 server/deps/express/node_modules/qs/support/should/test/should.test.js
  153. +133 −0 server/deps/express/node_modules/qs/test/querystring.test.js
  154. +19 −2 server/deps/express/package.json
  155. +1 −0 server/lib/controlServer.js
  156. +1 −1 server/test/functional/controlServer.test.js
  157. +1 −1 server/test/testExtensions.js
@@ -26,7 +26,7 @@ exports = module.exports = createServer;
* Framework version.
*/
-exports.version = '1.0.6';
+exports.version = '1.4.3';
/**
* Initialize a new `connect.HTTPServer` with the middleware
@@ -215,4 +215,4 @@ Server.prototype.handle = function(req, res, out) {
}
}
next();
-};
+};
@@ -16,23 +16,46 @@ var utils = require('../utils')
/**
* Enfore basic authentication by providing a `callback(user, pass)`,
- * which must return `true` in order to gain access. Populates
- * `req.remoteUser`.
+ * which must return `true` in order to gain access. Alternatively an async
+ * method is provided as well, invoking `callback(user, pass, callback)`. Populates
+ * `req.remoteUser`. The final alternative is simply passing username / password
+ * strings.
*
* Examples:
*
- * connect.createServer(
+ * connect(connect.basicAuth('username', 'password'));
+ *
+ * connect(
* connect.basicAuth(function(user, pass){
* return 'tj' == user & 'wahoo' == pass;
* })
* );
*
- * @param {Function} callback
+ * connect(
+ * connect.basicAuth(function(user, pass, fn){
+ * User.authenticate({ user: user, pass: pass }, fn);
+ * })
+ * );
+ *
+ * @param {Function|String} callback or username
* @param {String} realm
* @api public
*/
module.exports = function basicAuth(callback, realm) {
+ var username, password;
+
+ // user / pass strings
+ if ('string' == typeof callback) {
+ username = callback;
+ password = realm;
+ if ('string' != typeof password) throw new Error('password argument required');
+ realm = arguments[2];
+ callback = function(user, pass){
+ return user == username && pass == password;
+ }
+ }
+
realm = realm || 'Authorization Required';
return function(req, res, next) {
@@ -47,11 +70,23 @@ module.exports = function basicAuth(callback, realm) {
if ('Basic' != scheme) return badRequest(res);
- if (callback(credentials[0], credentials[1])) {
- req.remoteUser = credentials[0];
- next();
+ // async
+ if (callback.length >= 3) {
+ var pause = utils.pause(req);
+ callback(credentials[0], credentials[1], function(err, user){
+ if (err || !user) return unauthorized(res, realm);
+ req.remoteUser = user;
+ next();
+ pause.resume();
+ });
+ // sync
} else {
- unauthorized(res, realm);
+ if (callback(credentials[0], credentials[1])) {
+ req.remoteUser = credentials[0];
+ next();
+ } else {
+ unauthorized(res, realm);
+ }
}
}
};
@@ -56,6 +56,7 @@ function mime(req) {
exports = module.exports = function bodyParser(){
return function bodyParser(req, res, next) {
+ if ('GET' == req.method || 'HEAD' == req.method) return next();
var parser = exports.parse[mime(req)];
if (parser && !req.body) {
var data = '';
@@ -1,4 +1,3 @@
-
/*!
* Connect - errorHandler
* Copyright(c) 2010 Sencha Inc.
@@ -44,7 +43,7 @@ var utils = require('../utils')
* @api public
*/
-module.exports = function errorHandler(options){
+exports = module.exports = function errorHandler(options){
options = options || {};
// defaults
@@ -62,13 +61,14 @@ module.exports = function errorHandler(options){
if (~accept.indexOf('html')) {
fs.readFile(__dirname + '/../public/style.css', 'utf8', function(e, style){
fs.readFile(__dirname + '/../public/error.html', 'utf8', function(e, html){
- var stack = err.stack
+ var stack = (err.stack || '')
.split('\n').slice(1)
.map(function(v){ return '<li>' + v + '</li>'; }).join('');
html = html
.replace('{style}', style)
.replace('{stack}', stack)
- .replace(/\{error\}/g, err.toString());
+ .replace('{title}', exports.title)
+ .replace(/\{error\}/g, utils.escape(err.toString()));
res.setHeader('Content-Type', 'text/html');
res.end(html);
});
@@ -92,3 +92,9 @@ module.exports = function errorHandler(options){
}
};
};
+
+/**
+ * Template title.
+ */
+
+exports.title = 'Connect';
@@ -8,9 +8,6 @@
/**
* Limit request bodies to the given size in `bytes`.
*
- * When exceeded, the request will emit an "error" event,
- * and the limit can be checked via `error.limit`.
- *
* A string representation of the bytesize may also be passed,
* for example "5mb", "200kb", "1gb", etc.
*
@@ -20,6 +17,8 @@
* connect.limit('5.5mb')
* ).listen(3000);
*
+ * TODO: pause EV_READ
+ *
* @param {Number|String} bytes
* @return {Function}
* @api public
@@ -30,21 +29,26 @@ module.exports = function limit(bytes){
if ('number' != typeof bytes) throw new Error('limit() bytes required');
return function limit(req, res, next){
var received = 0
- , done;
+ , len = req.headers['content-length']
+ ? parseInt(req.headers['content-length'], 10)
+ : null;
+
+ // deny the request
+ function deny() {
+ req.destroy();
+ }
// self-awareness
if (req._limit) return next();
req._limit = true;
+ // limit by content-length
+ if (len && len > bytes) deny();
+
// limit
req.on('data', function(chunk){
received += chunk.length;
- if (received > bytes && !done) {
- done = true;
- var err = new Error('limit of ' + bytes + ' bytes exceeded');
- err.limit = bytes;
- req.emit('error', err);
- }
+ if (received > bytes) deny();
});
next();
@@ -41,16 +41,18 @@ var defaultBufferDuration = 1000;
* - `:user-agent`
* - `:status`
*
- * @param {String|Object} format or options
+ * @param {String|Function|Object} format or options
* @return {Function}
* @api public
*/
module.exports = function logger(options) {
- if ('string' == typeof options) {
+ if ('object' == typeof options) {
+ options = options || {};
+ } else if (options) {
options = { format: options };
} else {
- options = options || {};
+ options = {};
}
var fmt = options.format
@@ -83,7 +85,6 @@ module.exports = function logger(options) {
return function logger(req, res, next) {
var start = +new Date
, statusCode
- , resHeaders
, writeHead = res.writeHead
, end = res.end
, url = req.originalUrl;
@@ -98,8 +99,8 @@ module.exports = function logger(options) {
res.writeHead = function(code, headers){
res.writeHead = writeHead;
res.writeHead(code, headers);
- res._statusCode = statusCode = code;
- res._headers = resHeaders = headers || {};
+ res.__statusCode = statusCode = code;
+ res.__headers = headers || {};
};
// proxy end to output a line to the provided logger.
@@ -108,18 +109,27 @@ module.exports = function logger(options) {
res.end = end;
res.end(chunk, encoding);
res.responseTime = +new Date - start;
- stream.write(format(fmt, req, res) + '\n', 'ascii');
+ if ('function' == typeof fmt) {
+ var line = fmt(req, res, function(str){ return format(str, req, res); });
+ if (line) stream.write(line + '\n', 'ascii');
+ } else {
+ stream.write(format(fmt, req, res) + '\n', 'ascii');
+ }
};
} else {
res.end = function(chunk, encoding) {
+ var contentLength = (res._headers && res._headers['content-length'])
+ || (res.__headers && res.__headers['Content-Length'])
+ || '-';
+
res.end = end;
res.end(chunk, encoding);
- stream.write((req.socket && req.socket.remoteAddress)
+ stream.write((req.socket && (req.socket.remoteAddress || (req.socket.socket && req.socket.socket.remoteAddress)))
+ ' - - [' + (new Date).toUTCString() + ']'
+ ' "' + req.method + ' ' + url
+ ' HTTP/' + req.httpVersionMajor + '.' + req.httpVersionMinor + '" '
- + statusCode + ' ' + (resHeaders['Content-Length'] || '-')
+ + (statusCode || res.statusCode) + ' ' + contentLength
+ ' "' + (req.headers['referer'] || req.headers['referrer'] || '')
+ '" "' + (req.headers['user-agent'] || '') + '"\n', 'ascii');
};
@@ -143,13 +153,17 @@ function format(str, req, res) {
return str
.replace(':url', req.originalUrl)
.replace(':method', req.method)
- .replace(':status', res._statusCode)
+ .replace(':status', res.__statusCode || res.statusCode)
.replace(':response-time', res.responseTime)
.replace(':date', new Date().toUTCString())
.replace(':referrer', req.headers['referer'] || req.headers['referrer'] || '')
.replace(':http-version', req.httpVersionMajor + '.' + req.httpVersionMinor)
- .replace(':remote-addr', req.socket && req.socket.remoteAddress)
+ .replace(':remote-addr', req.socket && (req.socket.remoteAddress || (req.socket.socket && req.socket.socket.remoteAddress)))
.replace(':user-agent', req.headers['user-agent'] || '')
- .replace(/:req\[([^\]]+)\]/g, function(_, header){ return req.headers[header]; })
- .replace(/:res\[([^\]]+)\]/g, function(_, header){ return res._headers[header]; });
-}
+ .replace(/:req\[([^\]]+)\]/g, function(_, field){ return req.headers[field.toLowerCase()]; })
+ .replace(/:res\[([^\]]+)\]/g, function(_, field){
+ return res._headers
+ ? (res._headers[field.toLowerCase()] || res.__headers[field])
+ : (res.__headers && res.__headers[field]);
+ });
+}
Oops, something went wrong.

0 comments on commit c87069b

Please sign in to comment.