Merge branch 'net2_fixes' of git://github.com/ciaranj/express
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parents b30eaa8, 75c5305 · 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
Provenance
- Commit
bd74fe2- Tree
d27a17f- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent 1
b30eaa8- Parent 2
75c5305
4 files changed+34 added−13 removed
modified:examples/chat/app.js+1 added-1 removed
15 unmodified lines1617181920202122232455 unmodified lines15 unmodified lines use(Logger) set('root', __dirname)})
get('/', function(){get('/', function(){ this.pass('/chat')})
get('/chat', function(){ 55 unmodified linesmodified:lib/express/plugins/logger.js+4 added-3 removed
11 unmodified lines12131415161716171819202121222324252655 unmodified lines11 unmodified lines */ var formats = { common: function(event, start) { printf('%s - - [%s] "%s %s HTTP/%d" %s %d %0.3f', event.request.connection.remoteAddress, printf('%s - - [%s] "%s %s HTTP/%d.%d" %s %d %0.3f', event.request.socket.remoteAddress, (new Date).format('%d/%b/%Y %H:%M:%S'), event.request.method.uppercase, event.request.url.pathname || '/', event.request.httpVersion, event.request.httpVersionMajor, event.request.httpVersionMinor, event.request.response.status, event.request.response.headers['content-length'] || 0, (Number(new Date) - start) / 1000) },55 unmodified linesmodified:lib/express/core.js+5 added-3 removed
214 unmodified lines215 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 lines274 * @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 lines285 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 linesmodified:lib/express/request.js+24 added-6 removed
27 unmodified lines28 29 // --- Request30 31 exports.Request = new Class({32- 32 /**33 * Initialize with node's _request_ and _response_ objects.34 *35 * - Defaults headers to {}5 unmodified lines41 * @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 lines226 * @return {Request}227 * @api public228 */229 232- 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 lines273 this.header('content-disposition', path274 ? 'attachment; filename="' + path + '"'275 : 'attachment')276 return this277+ },278+279+ /* 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'],284+285+ /** 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 })