Skip to content
Myr

Added support for multi-part vals that are not files

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

authored by visionmedia · committed by visionmedia · parent 5fe35bf · Browse files · 2 files+17 added−8 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+17 added−8 removed

  • other:+17 added−8 removed

2 files+17 added−8 removed

modified:examples/upload/app.js+2 added
modified:lib/express/core.js+15 added-8 removed
219 unmodified lines
220 if (request.headers['content-type'] &&221 request.headers['content-type'].indexOf('multipart/form-data') !== -1) {222 var stream = new multipart.Stream(request)223 stream.addListener('part', function(part){224 request.params = { post: {}}225 if (part.filename) {226 var file = new File(part.tempfile = '/tmp/express-' + Number(new Date), 'w')227 part.pos = 0228 part.addListener('body', function(chunk){
1 unmodified line
230 part.pos += chunk.length231 })232 part.addListener('complete', function(){233 file.close()233 request.params = { post: mergeParam(part.name, part, {}) }234 mergeParam(part.name, part, request.params.post)235 })236 }236 })237 stream.addListener('complete', function(){238 self.route(request, response)239 })240 } else241 request.addListener('body', function(chunk){ request.body += chunk }),242 request.addListener('complete', function(){ self.route(request, response) })237 else238 part.buf = '',239 part240 .addListener('body', function(chunk){ part.buf += chunk })241 .addListener('complete', function(){242 mergeParam(part.name, part.buf, request.params.post)243 })244 }).addListener('complete', function(){ self.route(request, response) })245 }246 else247 request248 .addListener('body', function(chunk){ request.body += chunk })249 .addListener('complete', function(){ self.route(request, response) })250 })251 .listen(this.port, this.host, this.backlog)252 puts('Express started at http://' + this.host + ':' + this.port + '/ in ' + Express.environment + ' mode')253 },
62 unmodified lines