From e384e94be8cc8b2cd7c16e4a657ffef57cf8cbbc Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Fri, 22 Jul 2011 11:49:40 -0600 Subject: [PATCH] (test server) fix content-length: the number of bytes, not the number of chars (fun with node.js buffers!). --- run.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/run.js b/run.js index 187b1f1cf..5b5d870a7 100755 --- a/run.js +++ b/run.js @@ -101,9 +101,10 @@ function substitutionMiddleware(req, resp, next) { contentType.substr(0,4) === 'text')) { if (buf) { - var l = buf.length; + if (Buffer.isBuffer(buf)) buf = buf.toString('utf8'); + var l = Buffer.byteLength(buf); buf = subHostNames(buf); - if (l != buf.length) resp.setHeader('Content-Length', buf.length); + if (l != Buffer.byteLength(buf)) resp.setHeader('Content-Length', Buffer.byteLength(buf)); } } if (buf && buf.length) { -- GitLab