mirror of
https://github.com/zebrajr/express.git
synced 2026-01-15 12:15:27 +00:00
remove res.charset usage
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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('/')
|
||||
|
||||
Reference in New Issue
Block a user