if (on_body_v->IsFunction() == false) return 0;
Handle<Function> on_body = Handle<Function>::Cast(on_body_v);
- /* Look at the value of message_handler.encoding to decide how to
- * send the body chunk. This is rather sloppy and unnecesary. FIXME
- */
- enum encoding encoding = RAW;
- Local<Value> encoding_v = message_handler->Get(ENCODING_SYMBOL);
- if (encoding_v->IsString()) {
- Local<String> encoding_string = encoding_v->ToString();
- char buf[5]; // need enough room for "utf8" or "raw"
- encoding_string->WriteAscii(buf, 0, 4);
- buf[4] = '\0';
- if(strcasecmp(buf, "utf8") == 0)
- encoding = UTF8;
- }
-
Handle<Value> argv[1];
// TODO each message should have their encoding.
// don't look at the conneciton for encoding
- if(encoding == UTF8) {
+ if (connection->encoding_ == UTF8) {
// utf8 encoding
Handle<String> chunk = String::New((const char*)buf, len);
argv[0] = chunk;
, headers : [] // at onHeaderField, onHeaderValue
, onBody : null // by user
, onBodyComplete : null // by user
+ , setBodyEncoding : function (enc) {
+ connection.setEncoding(enc);
+ }
}
var res = new node.http.ServerResponse(connection, responses);
}).listen(port);
var c = new node.tcp.Connection();
+ c.setEncoding("utf8");
var req_sent = 0;
c.onConnect = function () {
//puts("send get");
c.onReceive = function (chunk) {
//puts("client recv");
- total += chunk.encodeUtf8();
+ total += chunk;
puts("total: " + JSON.stringify(total));
if ( req_sent == 1) {