diff --git a/lib/router/index.js b/lib/router/index.js index ef3f0c5..6188a84 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -33,8 +33,10 @@ router.createServer = function() { res.simpleJSON = function (code, obj) { var body = JSON.stringify(obj); + var m = encodeURIComponent(body).match(/%[89ABab]/g); + res.writeHead(code, [ ["Content-Type", "text/json"] - , ["Content-Length", body.length] + , ["Content-Length", (body.length + (m ? m.length : 0))] ]); res.write(body); res.end();