Defaulting mimetype to "application/octet-stream"
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 73d1d67 · Browse files · 3 files·+16 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
3 files+16 added−8 removed
- tests:+2 added−2 removed
- other:+14 added−6 removed
Provenance
- Commit
bd5e771- Tree
91a091a- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
73d1d67
3 files changed+16 added−8 removed
modified:lib/express.core.js+13 added-5 removed
34 unmodified lines35 */36 37 start : function(port) {38 this.server.listen(port || 3000, function(request, response){39- // TODO: hooks / modules39+ // TODO: middleware40 request.headers = Express.arrayToHash(request.headers)41 request.cookie = Express.parseCookie(request.headers['Cookie'])42 request.uri.params = Express.parseNestedParams(request.uri.params)43 request.uri.path = Express.normalizePath(request.uri.path)44 Express.request = request45 Express.response.cookie = request.cookie46 Express.response.body = Express.callRouteFor(request)47- response.sendHeader(Express.response.status, Express.prepareResponseHeaders(Express.hashToArray(Express.response.headers)))47+ Express.prepareCookie()48+ response.sendHeader(Express.response.status, Express.hashToArray(Express.response.headers))49 response.sendBody(Express.response.body || '')50 response.finish()51 })52 },13 unmodified lines66 puts('Express listening to http://localhost:' + port)67 }68 },69 69- prepareResponseHeaders : function(headers) {70- return headers70+ prepareCookie : function() {71+ p (this.response)72+ var cookie = []73+ for (var key in this.response.cookie)74+ if (this.response.cookie.hasOwnProperty(key))75+ cookie.push(key + '=' + this.response.cookie[key])76+ if (cookie.length)77+ this.header('Set-Cookie', cookie.join('; '))78 },79 80 /**81 * Return an associative array generated390 unmodified lines472 })473 474 get('cookies', function(){475 cookie('foo', 'bar')476+ cookie('some-thing', 'some value')477+ cookie('max-age', '1000')478 p(request.headers)479 p(response.headers)471- p(response.cookie)480 'Wahoo!'481 })482 483 get('articles', function(){16 unmodified linesmodified:lib/express.mime.js+1 added-1 removed
9 unmodified lines10111213141415161718165 unmodified linesExpand all9 unmodified lines
Express.mime = function(ext) { if (ext.indexOf('.') != -1) ext = ext.substring(ext.lastIndexOf('.') + 1, ext.length) return Express.mimeTypes[ext] return Express.mimeTypes[ext] || 'application/octet-stream'}
Express.mimeTypes = { "3gp" : "video/3gpp",165 unmodified linesExpand allmodified:spec/spec.mime.js+2 added-2 removed
3 unmodified lines45678989101112134 unmodified lines3 unmodified lines it 'should return media type of extensions passed' Express.mime('jpeg').should.eql 'image/jpeg' end it 'should return null when invalid' Express.mime('foobar').should.be_null it 'should return application/octet-stream when invalid' Express.mime('foobar').should.eql 'application/octet-stream' end it 'should parse extension of basename or path passed' Express.mime('images/profile.png').should.eql 'image/png'4 unmodified lines