diff --git a/lib/proxy.js b/lib/proxy.js index b0b3b86..81c4c55 100644 --- a/lib/proxy.js +++ b/lib/proxy.js @@ -81,6 +81,10 @@ Proxy.prototype.invoke = function(method, args, callback) { }); }); + req.on('error', function(err){ + callback(err); + }); + self.emit('call', data); req.write(data); req.end(); diff --git a/lib/reader2.js b/lib/reader2.js index 6c22e07..66a328c 100644 --- a/lib/reader2.js +++ b/lib/reader2.js @@ -229,6 +229,18 @@ Reader.prototype.readClassDef = function(data) { } }; +function getLengthOfUTF8(head){ + if (head < 0x80) { + return 1; + } + if ((head & 0xe0) === 0xc0) { + return 2; + } + + if ((head & 0xf0) === 0xe0) { + return 3; + } +} Reader.prototype.readString = function(data) { if (data) @@ -236,7 +248,14 @@ Reader.prototype.readString = function(data) { var code = this.reader.nextUInt8(); if (code >= 0 && code < 32) { - return this.reader.nextString(code); + var strs = []; + while (code--) { + var strHead = this.reader.nextBuffer(1); + var len = getLengthOfUTF8(strHead[0]); + this.reader.move(-1); + strs.push(this.reader.nextString(len)); + } + return strs.join(''); } else if (code >= 0x30 && code <= 0x33) { this.reader.move(-1); var len = this.reader.nextUInt16BE() - 0x3000;