.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 62b9a9e · Browse files · 2 files·+19 added−23 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+19 added−23 removed
- other:+19 added−23 removed
Provenance
- Commit
d576085- Tree
ad05310- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
62b9a9e
2 files changed+19 added−23 removed
modified:lib/express/core.js+17 added-21 removed
213 unmodified lines214 if (host !== undefined) this.host = host215 if (port !== undefined) this.port = port216 if (backlog !== undefined) this.backlog = backlog217 require('http')218- .createServer(function(request, response){219- request.body = ''220- request.setBodyEncoding('binary')218+ .createServer(function(req, response){219+ var request, pendingFiles = 0220+ req.body = ''221+ req.setBodyEncoding('binary')222+ request = new Request(req, response)223 function callback(err) {222- if (!(request instanceof Request))223- request = new Request(request, response)224 if (err)225 request.error(err)226 else if (!pendingFiles)227- self.route(request, response)227+ self.route(request)228 }229- if (request.headers['content-type'] &&230- request.headers['content-type'].includes('multipart/form-data')) {231- var stream = multipart.parse(request),232- contentLength = parseInt(request.headers['content-length']),233- maxBodyLength = set('max upload size'),234- pendingFiles = 0229+ if (request.header('content-type') &&230+ request.header('content-type').includes('multipart/form-data')) {231+ var stream = multipart.parse(req),232+ contentLength = parseInt(request.header('content-length')),233+ maxBodyLength = set('max upload size')234 if (maxBodyLength && contentLength > maxBodyLength)235 return callback(new Error('upload size limit exceeded'))237- request.params = { post: {}}236 stream237 .addListener('partBegin', function(part) {238 if (part.filename)239 ++pendingFiles,23 unmodified lines263 .addListener('error', callback)264 .addListener('complete', callback)265 }266 else269- request270- .addListener('data', function(chunk){ request.body += chunk })267+ req268+ .addListener('data', function(chunk){ req.body += chunk })269 .addListener('end', callback)270 })271 .listen(this.port, this.host, this.backlog)272 puts('Express started at http://' + this.host + ':' + this.port + '/ in ' + Express.environment + ' mode')273 },274 275 /**278- * Route the given _request_ and _response_.276+ * Route the given _request_.277 *280- * @param {object} request281- * @param {object} response278+ * @param {Request} request279 * @api private280 */281 285- route: function(request, response){ 286- var self = this,287- request = new Request(request, response)282+ route: function(request){ 283+ var self = this284 request.trigger('request', function(err) {285 try {286 if (err) throw err287 if (request.response.finished) return46 unmodified linesmodified:lib/express/request.js+2 added-2 removed
49 unmodified lines50 response.headers = {}51 this.response = response 52 this.url = url.parse(this.url)53 this.url.pathname = exports.normalizePath(this.url.pathname) 54- this.params = this.params || {}55- this.params.path = {}54+ this.params = {}55+ this.params.path = {}56 this.params.get = this.url.query ? queryString.parseQuery(this.url.query) : {}57 this.params.post = this.params.post || {}58 this.plugins = Express.plugins.map(function(plugin){59 return new plugin.klass(plugin.options) 299 unmodified lines