Skip to content

Commit

Permalink
JSON and JSONP default to UTF-8 in the same way as HTML. Closes expre…
Browse files Browse the repository at this point in the history
…ssjs#632.

Signed-off-by: Tj Holowaychuk <tj@vision-media.ca>
  • Loading branch information
dshaw authored and tj committed Apr 20, 2011
1 parent 8f054db commit 3afbcd0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ res.send = function(body, headers, status){
break;
case 'string':
if (!this.header('Content-Type')) {
this.charset = this.charset || this.app.set('charset') || 'utf-8';
this.charset = this.charset || 'utf-8';
this.contentType('.html');
}
break;
Expand All @@ -75,12 +75,12 @@ res.send = function(body, headers, status){
}
} else {
if (!this.header('Content-Type')) {
this.charset = this.charset || this.app.set('charset') || 'utf-8';
this.charset = this.charset || 'utf-8';
this.contentType('.json');
}
body = JSON.stringify(body);
if (this.req.query.callback && this.app.set('jsonp callback')) {
this.charset = this.charset || this.app.set('charset') || 'utf-8';
this.charset = this.charset || 'utf-8';
this.header('Content-Type', 'text/javascript');
body = this.req.query.callback.replace(/[^\w$.]/g, '') + '(' + body + ');';
}
Expand Down

0 comments on commit 3afbcd0

Please sign in to comment.