Skip to content
Myr

Added BodyDecoder plugin, required by core

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

authored by visionmedia · committed by visionmedia · parent 57f8e82 · Browse files · 7 files+43 added−32 removed
This commit

State

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

Diff stats

7 files+43 added−32 removed

  • tests:+27 added−24 removed
  • other:+16 added−8 removed

7 files+43 added−32 removed

added:lib/express/plugins/body-decoder.js+15 added
modified:lib/express/plugins/redirect.js-4 removed
modified:lib/express/core.js+1 added
255 unmodified lines
256// --- Defaults257258configure(function(){259 set('views', function(){ return set('root') + '/views' })260 use(require('express/plugins/body-decoder').BodyDecoder)261})262263configure('test', function(){264 enable('throw exceptions')
1 unmodified line
modified:lib/express/request.js-4 removed
98 unmodified lines
99 this.uri.params = parseNestedParams(this.uri.params)100 this.plugins = $(Express.plugins).map(function(plugin){101 return new plugin.klass(plugin.options) 102 })103 this.uri.post = 104 this.header('content-type') && this.header('content-type').indexOf('application/x-www-form-urlencoded') > -1 ?105 parseParams(this.body) :106 {}103 },104 105 /**106 * Set response header _key_ and _val_ or get
129 unmodified lines
modified:spec/spec.node.js+1 added
added:spec/spec.plugins.body-decoder.js+26 added
modified:spec/spec.request.js-24 removed
2 unmodified lines
3 before_each4 reset()5 end6 7 describe '#init()'8 describe 'when content-type is "application/x-www-form-urlencoded"'9 it 'should parse body as urlencoded params'10 post('/login', function(){11 return this.param('name')12 })13 var response = post('/login', { body: 'name=tj', headers: { 'content-type': 'application/x-www-form-urlencoded' }})14 response.status.should.eql 20015 response.body.should.eql 'tj'16 end17 18 describe 'with charset'19 it 'should parse body as urlencoded params'20 post('/login', function(){21 return this.param('name')22 })23 var response = post('/login', { body: 'name=tj', headers: { 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8' }})24 response.status.should.eql 20025 response.body.should.eql 'tj'26 end27 end28 end29 end307 describe 'status()'8 it 'should set the response status'9 get('/user', function(){ this.status(500) })10 get('/user').status.should.eql 500
141 unmodified lines