Permalink
Browse files

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

This is same error that was fixed in 216fb3b.

Reported by Felix Geisendörfer.
  • Loading branch information...
1 parent 65ec2d5 commit 75fc21537a408135a0147f97a9ef0de800bbbfc8 @ry ry committed Aug 9, 2009
Showing with 7 additions and 7 deletions.
  1. +6 −6 src/http.cc
  2. +1 −1 test/mjsunit/test-http.js
View
@@ -192,19 +192,19 @@ 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<String> chunk = String::New((const char*)buf, len);
- argv[0] = chunk;
-
- } else {
+ if (connection->encoding_ == RAW) {
// raw encoding
Local<Array> array = Array::New(len);
for (size_t i = 0; i < len; i++) {
char val = static_cast<const char*>(buf)[i];
array->Set(Integer::New(i), Integer::New(val));
}
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);
@@ -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");
});

0 comments on commit 75fc215

Please sign in to comment.