From ea4ed864c87ddb6c92351298fd1fcfbc082887f9 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Thu, 25 Apr 2013 16:36:56 -0500 Subject: [PATCH] Fix content-length bug for api.js Well, it finally happened. I made an assumption about text and it bit me in the butt. Protip: not everything is 1 byte per character! --- api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api.js b/api.js index 2af79919..e13f96e7 100644 --- a/api.js +++ b/api.js @@ -92,9 +92,10 @@ function handleChannelData(params, req, res) { } var response = JSON.stringify(data, null, 4); + var len = unescape(encodeURIComponent(response)).length; res.setHeader("Content-Type", "application/json"); - res.setHeader("Content-Length", response.length); + res.setHeader("Content-Length", len); res.end(response); }