remove res.charset usage

This commit is contained in:
Jonathan Ong
2014-03-07 16:46:54 -08:00
parent 3228fd3cbc
commit 2064f412cb
2 changed files with 5 additions and 13 deletions

View File

@@ -106,10 +106,7 @@ res.send = function(body){
break;
// string defaulting to html
case 'string':
if (!this.get('Content-Type')) {
this.charset = this.charset || 'utf-8';
this.type('html');
}
if (!this.get('Content-Type')) this.type('html');
break;
case 'boolean':
case 'object':
@@ -189,7 +186,6 @@ res.json = function(obj){
var body = JSON.stringify(obj, replacer, spaces);
// content-type
this.charset = this.charset || 'utf-8';
this.get('Content-Type') || this.set('Content-Type', 'application/json');
return this.send(body);
@@ -233,7 +229,6 @@ res.jsonp = function(obj){
var callback = this.req.query[app.get('jsonp callback name')];
// content-type
this.charset = this.charset || 'utf-8';
this.set('Content-Type', 'application/json');
// jsonp
@@ -467,10 +462,7 @@ res.format = function(obj){
this.vary("Accept");
if (key) {
var type = normalizeType(key).value;
var charset = mime.charsets.lookup(type);
if (charset) type += '; charset=' + charset;
this.set('Content-Type', type);
this.set('Content-Type', normalizeType(key).value);
obj[key](req, this, next);
} else if (fn) {
fn();

View File

@@ -93,7 +93,7 @@ function test(app) {
request(app)
.get('/')
.set('Accept', 'text/html; q=.5, text/plain')
.expect('Content-Type', 'text/plain; charset=UTF-8')
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect('hey', done);
})
@@ -101,12 +101,12 @@ function test(app) {
request(app)
.get('/')
.set('Accept', 'text/html')
.expect('Content-Type', 'text/html; charset=UTF-8');
.expect('Content-Type', 'text/html; charset=utf-8');
request(app)
.get('/')
.set('Accept', 'text/plain')
.expect('Content-Type', 'text/plain; charset=UTF-8');
.expect('Content-Type', 'text/plain; charset=utf-8');
request(app)
.get('/')