Giter Site home page Giter Site logo

hessian-client's People

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

cyrusmg

hessian-client's Issues

Request tries to 'stringify' the binary content which can lead to incorrect data being processed.

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) {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.