From 75fc21537a408135a0147f97a9ef0de800bbbfc8 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 9 Aug 2009 18:04:10 +0200 Subject: [PATCH] Bugfix: response.setBodyEncoding("ascii") not working. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is same error that was fixed in 216fb3b9b2811444228d7af7a450839e58b80713. Reported by Felix Geisendörfer. --- src/http.cc | 12 ++++++------ test/mjsunit/test-http.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/http.cc b/src/http.cc index 0ea0909afa..945d98856b 100644 --- a/src/http.cc +++ b/src/http.cc @@ -192,12 +192,7 @@ HTTPConnection::on_body (http_parser *parser, const char *buf, size_t len) // TODO each message should have their encoding. // don't look at the conneciton for encoding - if (connection->encoding_ == UTF8) { - // utf8 encoding - Handle chunk = String::New((const char*)buf, len); - argv[0] = chunk; - - } else { + if (connection->encoding_ == RAW) { // raw encoding Local array = Array::New(len); for (size_t i = 0; i < len; i++) { @@ -205,6 +200,11 @@ HTTPConnection::on_body (http_parser *parser, const char *buf, size_t len) array->Set(Integer::New(i), Integer::New(val)); } argv[0] = array; + + } else { + // utf8 or ascii encoding + Handle chunk = String::New((const char*)buf, len); + argv[0] = chunk; } connection->Emit("body", 1, argv); diff --git a/test/mjsunit/test-http.js b/test/mjsunit/test-http.js index 83c8a36140..94a1905303 100644 --- a/test/mjsunit/test-http.js +++ b/test/mjsunit/test-http.js @@ -34,7 +34,7 @@ function onLoad () { req.finish(function (res) { assertEquals(200, res.statusCode); responses_recvd += 1; - res.setBodyEncoding("utf8"); + res.setBodyEncoding("ascii"); res.addListener("body", function (chunk) { body0 += chunk; }); node.debug("Got /hello response"); });