Skip to content
Myr

Added "encoding" option to Request#render(). Closes #299

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

Should work :)

authored by visionmedia · committed by visionmedia · parent 8108876 · Browse files · 3 files+24 added−1 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+24 added−1 removed

  • tests:+13 added−0 removed
  • other:+11 added−1 removed

3 files+24 added−1 removed

modified:lib/express/plugins/view.js+2 added-1 removed
modified:lib/express/request.js+9 added
174 unmodified lines
175 encoding = null176 this.status(code = code || 404)177 if (body !== null)178 body = body || statusBodies[code]179 if (encoding === 'utf8' ||180 encoding === 'utf-8')181 this.charset = 'UTF-8'182 return this.respond(body, encoding, callback)183 },184 185 /**
56 unmodified lines
242 243 /**244 * Send the response header.245 *246 * If Request#charset is defined, and the247 * "Content-Type" header, then "; charset=CHARSET" is248 * appended.249 *250 * @return {Request}251 * @api public252 */253 254 sendHead: function(){255 if (this.charset && this.response.headers['Content-Type'])256 this.response.headers['Content-Type'] += '; charset=' + this.charset257 this.response.writeHead(this.response.status, this.response.headers)258 return this259 },260
159 unmodified lines
modified:spec/spec.request.js+13 added
9 unmodified lines
10 get('/user', function(){ this.status(500) })11 get('/user').status.should.eql 50012 end13 end14 15 describe '#charset'16 describe 'when defined'17 it 'should append "; charset=CHARSET'18 get('/user', function(){19 this.contentType('html')20 this.charset = 'UTF-8'21 return '∂'22 })23 get('/user').headers['Content-Type'].should.eql 'text/html; charset=UTF-8'24 end25 end26 end2728 describe '#header()'29 describe 'when given a field name and value'30 it 'should set the header'
390 unmodified lines