Skip to content
Myr

JSON and JSONP default to UTF-8 in the same way as HTML. Closes #632.

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

authored by Daniel Shaw · committed by Tj Holowaychuk · parent 8f054db · Browse files · 1 file+3 added−3 removed
This commit

State

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

Trailers

  • Signed-off-by: Tj Holowaychuk <tj@vision-media.ca>

Diff stats

1 file+3 added−3 removed

  • other:+3 added−3 removed

1 file+3 added−3 removed

modified:lib/response.js+3 added-3 removed
61 unmodified lines
62 body = http.STATUS_CODES[status = body];63 break;64 case 'string':65 if (!this.header('Content-Type')) {66 this.charset = this.charset || this.app.set('charset') || 'utf-8';66 this.charset = this.charset || 'utf-8';67 this.contentType('.html');68 }69 break;70 case 'boolean':
3 unmodified lines
74 this.contentType('.bin');75 }76 } else {77 if (!this.header('Content-Type')) {78 this.charset = this.charset || this.app.set('charset') || 'utf-8';78 this.charset = this.charset || 'utf-8';79 this.contentType('.json');80 }81 body = JSON.stringify(body);82 if (this.req.query.callback && this.app.set('jsonp callback')) {83 this.charset = this.charset || this.app.set('charset') || 'utf-8';83 this.charset = this.charset || 'utf-8';84 this.header('Content-Type', 'text/javascript');85 body = this.req.query.callback.replace(/[^\w$.]/g, '') + '(' + body + ');';86 }87 }
335 unmodified lines