Skip to content
Myr

Various minor fixes required to make express work post the net2 merge branch

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ciaranj · committed by ciaranj · parent 3b49821 · Browse files · 4 files+34 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+34 added−13 removed

  • other:+34 added−13 removed

4 files+34 added−13 removed

modified:examples/chat/app.js+1 added-1 removed
modified:lib/express/plugins/logger.js+4 added-3 removed
modified:lib/express/core.js+5 added-3 removed
214 unmodified lines
215 require('http')216 .createServer(function(request, response){217 request.body = ''218 request.setBodyEncoding('binary')219 var pendingFiles220 219 function callback(e, result) {221 function callback(e, result) { 222 if (e)223 self.error(e, request, response)224 else if (!pendingFiles)225 self.route(request, response)
48 unmodified lines
274 * @param {object} response275 * @api private276 */277 276 route: function(request, response){278 route: function(request, response){ 279 var self = this,280 request = new Request(request, response) 281 request.trigger('request', function(e) {282 try {
2 unmodified lines
285 if (typeof (body = (new Router(request)).route()) === 'string')286 request.halt(200, body) 287 } catch (e) {288 self.error(e, request)287 }289 } 290 })291 },292 293 /**
54 unmodified lines
modified:lib/express/request.js+24 added-6 removed
27 unmodified lines
2829// --- Request3031exports.Request = new Class({32 32 /**33 * Initialize with node's _request_ and _response_ objects.34 *35 * - Defaults headers to {}
5 unmodified lines
41 * @param {object} request42 * @param {object} response43 * @api private44 */46 45 constructor: function(request, response) {48 utils.mixin(true, this, request)46 this._blendInNodeRequest(request)47 response.headers = {}50 this.response = response48 this.response = response 49 this.url = url.parse(this.url)52 this.url.pathname = exports.normalizePath(this.url.pathname)50 this.url.pathname = exports.normalizePath(this.url.pathname) 51 this.params = this.params || {}52 this.params.path = {}53 this.params.get = this.url.query ? queryString.parseQuery(this.url.query) : {}54 this.params.post = this.params.post || {}
171 unmodified lines
226 * @return {Request}227 * @api public228 */229232 trigger: function(name, data, callback) {230 trigger: function(name, data, callback) { 231 if (data instanceof Function)232 callback = data,233 data = null234 data = data || {}
38 unmodified lines
273 this.header('content-disposition', path274 ? 'attachment; filename="' + path + '"'275 : 'attachment')276 return this277 },278279 /* Properties that should be blended/mixed in from the node.js request object */280 _blendedProperties: ['socket', 'httpVersion','headers',281 'url', 'method',282 'httpVersionMajor','httpVersionMinor',283 'body','_encoding', '_events'],284285 /** 286 * Given a node.js Request object, blend in the shared properties287 * for an express Request object288 * 289 * @param {Request} request The node.js Request object.290 * @api private291 */292 _blendInNodeRequest: function(request) {293 for(var i=0;i<this._blendedProperties.length;i++) {294 var prop= this._blendedProperties[i]295 this[prop]= request[prop]296 }297 }298})