Added ContentLength plugin
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 467723f · Browse files · 5 files·+66 added−22 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+66 added−22 removed
- tests:+53 added−22 removed
- other:+13 added−0 removed
Provenance
- Commit
dea4ac9- Tree
f74246c- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
467723f
5 files changed+66 added−22 removed
modified:lib/express/plugins/content-length.js+13 added
12345678910111213
// Express - ContentLength - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
exports.ContentLength = Plugin.extend({ on: { response: function(event) { var response = event.response response.headers['content-length'] = response.headers['content-length'] || response.body.length } }})No newline at end of filemodified:spec/spec.node.js+2 added-1 removed
26 unmodified lines27282930313132333426 unmodified lines .exec('spec/spec.helpers.js') .exec('spec/spec.mime.js') .exec('spec/spec.collection.js') .exec('spec/spec.plugins.js') .exec('spec/spec.plugins.logger.js') .exec('spec/spec.plugins.common-logger.js') .exec('spec/spec.plugins.content-length.js')JSpec.run({ formatter: JSpec.formatters.Terminal, failuresOnly: true })JSpec.report()added:spec/spec.plugins.common-logger.js+23 added
1234567891011121314151617181920212223
describe 'Express' before_each reset() use(require('express/plugins/common-logger').Logger) end describe 'Logger' describe 'on' describe 'response' it 'should output in common log format' GLOBAL.stub('puts') GLOBAL.should.receive('puts') get('/style.css', function(){ contentType('css') return 'body { background: #000; }' }) get('/style.css') end end end endendNo newline at end of fileadded:spec/spec.plugins.content-length.js+28 added
12345678910111213141516171819202122232425262728
describe 'Express' before_each reset() use(require('express/plugins/content-length').ContentLength) end describe 'ContentLength' describe 'on' describe 'response' it 'should set the content-length header' get('/style.css', function(){ return 'body { background: #000; }' }) get('/style.css').headers['content-length'].should.eql 26 end it 'should not override when manually set' get('/style.css', function(){ header('content-length', 10) return 'body { background: #000; }' }) get('/style.css').headers['content-length'].should.eql 10 end end end endendNo newline at end of filedeleted:spec/spec.plugins.logger.js-21 removed
123456789101112131415161718192021
describe 'Express' before_each reset() end describe 'Logger' describe 'events' it 'should output in common log format' GLOBAL.stub('puts') GLOBAL.should.receive('puts') use(require('express/plugins/common-logger').Logger) get('/style.css', function(){ contentType('css') return 'body { background: #000; }' }) get('/style.css') end end endendNo newline at end of file