From e29dddb014302527709c54498ec6575478015032 Mon Sep 17 00:00:00 2001 From: Dmitry Minkovsky Date: Fri, 27 Jun 2014 08:45:17 -0700 Subject: [PATCH] `content-length` header should be byte length, not character length. --- FAQ.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FAQ.md b/FAQ.md index 743e616..e3b281d 100644 --- a/FAQ.md +++ b/FAQ.md @@ -47,7 +47,7 @@ http.createServer(function(req, res) { pg.query(..., function(err, result) { //NOTE: error handling not present var json = JSON.stringify(result.rows); - res.writeHead(200, {'content-type':'application/json', 'content-length':json.length}); + res.writeHead(200, {'content-type':'application/json', 'content-length':Buffer.byteLength(json)}); res.end(json); }); })