Browse Source

Bugfix: response.setBodyEncoding("ascii") not working.

This is same error that was fixed in 216fb3b9b2.

Reported by Felix Geisendörfer.
v0.7.4-release
Ryan 16 years ago
parent
commit
75fc21537a
  1. 12
      src/http.cc
  2. 2
      test/mjsunit/test-http.js

12
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. // TODO each message should have their encoding.
// don't look at the conneciton for encoding // don't look at the conneciton for encoding
if (connection->encoding_ == UTF8) { if (connection->encoding_ == RAW) {
// utf8 encoding
Handle<String> chunk = String::New((const char*)buf, len);
argv[0] = chunk;
} else {
// raw encoding // raw encoding
Local<Array> array = Array::New(len); Local<Array> array = Array::New(len);
for (size_t i = 0; i < len; i++) { 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)); array->Set(Integer::New(i), Integer::New(val));
} }
argv[0] = array; argv[0] = array;
} else {
// utf8 or ascii encoding
Handle<String> chunk = String::New((const char*)buf, len);
argv[0] = chunk;
} }
connection->Emit("body", 1, argv); connection->Emit("body", 1, argv);

2
test/mjsunit/test-http.js

@ -34,7 +34,7 @@ function onLoad () {
req.finish(function (res) { req.finish(function (res) {
assertEquals(200, res.statusCode); assertEquals(200, res.statusCode);
responses_recvd += 1; responses_recvd += 1;
res.setBodyEncoding("utf8"); res.setBodyEncoding("ascii");
res.addListener("body", function (chunk) { body0 += chunk; }); res.addListener("body", function (chunk) { body0 += chunk; });
node.debug("Got /hello response"); node.debug("Got /hello response");
}); });

Loading…
Cancel
Save