Finished https support
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 72511ea · Browse files · 2 files·+21 added−69 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+21 added−69 removed
- other:+21 added−69 removed
Provenance
- Commit
54eac36- Tree
e37866e- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
72511ea
2 files changed+21 added−69 removed
modified:lib/http.js+20 added-15 removed
7 unmodified lines8 /**9 * Module dependencies.10 */11 12-var queryString = require('querystring')12+var qs = require('qs')13 , connect = require('connect')14 , router = connect.router15 , methods = router.methods.concat(['del', 'all'])16 , view = require('./view')7 unmodified lines24 * @api public25 */26 27 var Server = exports = module.exports = function HTTPServer(middleware){28+ connect.HTTPServer.call(this, []);29+ this.init(middleware);30+};31+32+/**33+ * Inherit from `connect.HTTPServer`.34+ */35+36+Server.prototype.__proto__ = connect.HTTPServer.prototype;37+38+/**39+ * Initialize the server.40+ *41+ * @param {Array} middleware42+ * @api private43+ */44+45+Server.prototype.init = function(middleware){46 var self = this;47 this.settings = {};48 this.redirects = {};49 this.isCallbacks = {};50 this.viewHelpers = {};51 this.dynamicViewHelpers = {};52 this.errorHandlers = [];35- connect.HTTPServer.call(this, []);53 54 // Default "home" to / 55 this.set('home', '/');56 10 unmodified lines67 req.next = next;68 // Assign req.params.get69 if (req.url.indexOf('?') > 0) {70 var query = url.parse(req.url).query;54- req.query = exports.parseQueryString(query);71+ req.query = qs.parse(query);72 }73 next();74 });75 17 unmodified lines93 });94 };95 96 /**80- * Inherit from `connect.HTTPServer`.81- */82-83-Server.prototype.__proto__ = connect.HTTPServer.prototype;84-85-/**86- * Support swappable querystring parsers.87- */88-89-exports.parseQueryString = queryString.parse;90-91-/**97 * Proxy in order to register error handlers.98 */99 100 Server.prototype.listen = function(){363 unmodified linesmodified:lib/https.js+1 added-54 removed
21 unmodified lines2223242526272829303132263435363738394041424344454647484950515253545556575859606162636465666768697071727374272829303132333435838485868788363738394021 unmodified lines * @api public */
var Server = exports = module.exports = function HTTPSServer(options, middleware){ var self = this; this.settings = {}; this.redirects = {}; this.isCallbacks = {}; this.viewHelpers = {}; this.dynamicViewHelpers = {}; this.errorHandlers = []; connect.HTTPSServer.call(this, options, []);
// Default "home" to / this.set('home', '/');
// Set "env" to NODE_ENV, defaulting to "development" this.set('env', process.env.NODE_ENV || 'development');
// Expose objects to each other this.use(function(req, res, next){ req.query = req.query || {}; res.headers = { 'X-Powered-By': 'Express' }; req.app = res.app = self; req.res = res; res.req = req; req.next = next; // Assign req.params.get if (req.url.indexOf('?') > 0) { var query = url.parse(req.url).query; req.query = exports.parseQueryString(query); } next(); });
// Apply middleware if (middleware) { middleware.forEach(function(fn){ self.use(fn); }); }
// Use router, expose as app.get(), etc var fn = router(function(app){ self.routes = app; }); this.__defineGetter__('router', function(){ this.__usedRouter = true; return fn; });
// Default production configuration this.configure('production', function(){ this.enable('cache views'); }); this.init(middleware);};
/** * Inherit from `connect.HTTPSServer`. */
Server.prototype.__proto__ = connect.HTTPSServer.prototype;
/** * Support swappable querystring parsers. */
exports.parseQueryString = queryString.parse;
// mixin HTTPServer methods
Object.keys(HTTPServer.prototype).forEach(function(method){ Server.prototype[method] = HTTPServer.prototype[method];});