check `content-type` for charset
jonathanong opened this issue · comments
jongleberry commented
would be cool to be check the .type
for the charset, then re-encode properly instead of doing a global charset. for example:
app.use(charset())
app.use(function* (next) {
var charset = this.acceptsCharsets('utf8', 'gbk') || 'utf8'
this.vary('accept-charset')
this.type = 'text/plain; charset=' + charset
this.body = 'something'
})
then this middleware will automatically re-encode the body only if the charset is not utf8
.