honestcheng / hessian-client Goto Github PK
View Code? Open in Web Editor NEWa simple hessian client, wrap the hessian.js, for personal use,only support hessian v1 now
License: MIT License
a simple hessian client, wrap the hessian.js, for personal use,only support hessian v1 now
License: MIT License
While using this library I have encountered weird 0xef, 0xbf, 0xbd
sequences where a single byte value should be present. After a lot of digging I have found the issue is in the request
call. Without encoding: null
the request returns a decoded-string which is then re-encoded to ByteArray.
Patch to fix this issue:
diff --git a/hessian.coffee b/hessian.coffee
index ced78ce..9b47b17 100644
--- a/hessian.coffee
+++ b/hessian.coffee
@@ -21,14 +21,14 @@ class HessianClient
buf
parse_response= (res_data) ->
- buf = new Buffer res_data
- hessianjs.decode(buf[3..-1])
+ hessianjs.decode(res_data[3..-1])
option =
url: @url
headers: {'Content-Type': 'application/binary'}
method: 'POST'
+ encoding: null
body: build_post_data(method, args)
cb = (error, res, body) ->
diff --git a/hessian.js b/hessian.js
index d95e42a..f52b163 100644
--- a/hessian.js
+++ b/hessian.js
@@ -28,9 +28,7 @@
return buf;
};
parse_response = function(res_data) {
- var buf;
- buf = new Buffer(res_data);
- return hessianjs.decode(buf.slice(3));
+ return hessianjs.decode(res_data.slice(3));
};
option = {
url: this.url,
@@ -38,6 +36,7 @@
'Content-Type': 'application/binary'
},
method: 'POST',
+ encoding: null,
body: build_post_data(method, args)
};
cb = function(error, res, body) {
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.