Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
node_modules
*.log
jar/
jar/
.idea
8 changes: 4 additions & 4 deletions lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var url = require('url'),
Reader2 = require('./reader2');


function Proxy(uri, username, password, proxy) {
function Proxy(uri, username, password) {
events.EventEmitter.call(this);
var parsed = url.parse(uri);

Expand All @@ -24,13 +24,12 @@ function Proxy(uri, username, password, proxy) {

assert((this.protocol == 'http' || this.protocol == 'https'), 'Unsupported Hessian protocal: ' + this.protocol);
this.version = 2;
this.proxy = proxy;
}

util.inherits(Proxy, events.EventEmitter);


Proxy.prototype.invoke = function(method, args, callback) {
Proxy.prototype.invoke = function(method, apiClassHeader, args, callback) {

var self = this,
WriterClz = (this.version === 1) ? Writer : Writer2,
Expand All @@ -42,7 +41,8 @@ Proxy.prototype.invoke = function(method, args, callback) {
port: this.port,
path: this.pathname,
headers: {
'Content-Type': 'application/binary'
'Content-Type': 'application/binary',
'apiClass': apiClassHeader
},
method: 'POST'
};
Expand Down
14 changes: 8 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ describe('hessian 1.0 test', function() {
proxy.version = 1;
});

function MAKE_ARGTEST(method, args) {
function MAKE_ARGTEST(method, apiClassHeader, args) {
it(method, function(done) {
proxy.invoke(method, args, function(err, res) {
proxy.invoke(method, apiClassHeader, args, function(err, res) {
assert.isTrue(res);
done(err);
});
});
}

it('methodNull', function(done) {
proxy.invoke('methodNull', [], function(err, res) {
proxy.invoke('methodNull', "", [], function(err, res) {
assert.isNull(res);
done(err);
});
});

it('replyNull', function(done) {
proxy.invoke('replyNull', null, function(err, res) {
proxy.invoke('replyNull', "", null, function(err, res) {
assert.isNull(res);
done(err);
});
Expand All @@ -44,9 +44,10 @@ describe('hessian 1.0 test', function() {
var dates = [new Date(0), new Date(1998, 4, 8, 7, 51), new Date(1998, 4, 8, 7, 51)];
var method = 'argDate_1',
arg = dates[1];
var apiClassHeader = "";

it(method, function(done) {
proxy.invoke(method, [arg], function(err, res) {
proxy.invoke(method, apiClassHeader, [arg], function(err, res) {
console.log(res);
done(err);
});
Expand Down Expand Up @@ -139,8 +140,9 @@ describe('hessian 1.0 test', function() {
assert.isNumber(arg);
// MAKE_ARGTEST('argDouble_' + name, [arg]);
var method = 'argDouble_' + name;
var apiClassHeader = "";
it(method, function(done) {
proxy.invoke(method, [arg], function(err, res) {
proxy.invoke(method, apiClassHeader, [arg], function(err, res) {
// assert.isTrue(res);
if (res !== true)
console.log(res.toString());
Expand Down
10 changes: 5 additions & 5 deletions test/test2.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ describe('hessian 2.0 test', function() {


it('methodNull', function(done) {
proxy.invoke('methodNull', [], function(err, res) {
proxy.invoke('methodNull', "", [], function(err, res) {
assert.isNull(res);
done(err);
});
});

function MAKE_ARGTEST(method, args, as) {
it(method, function(done) {
proxy.invoke(method, args, function(err, res) {
proxy.invoke(method, "", args, function(err, res) {
if (as) as(res);
else assert.isTrue(res);
done(err);
Expand All @@ -58,7 +58,7 @@ describe('hessian 2.0 test', function() {

function MAKE_REPLYTEST(method, reply, as) {
it(method, function(done) {
proxy.invoke(method, [], function(err, res) {
proxy.invoke(method, "", [], function(err, res) {
if (as) as(res, reply);
else assert.strictEqual(res, reply);
done(err);
Expand Down Expand Up @@ -373,7 +373,7 @@ describe('hessian 2.0 test', function() {
// MAKE_ARGTEST('argDouble_' + name, [arg]);
var method = 'argDouble_' + name;
it(method, function(done) {
proxy.invoke(method, [{
proxy.invoke(method, "", [{
val: arg,
type: 'double'
}], function(err, res) {
Expand All @@ -383,7 +383,7 @@ describe('hessian 2.0 test', function() {
});

it('replyDouble_' + name, function(done) {
proxy.invoke('replyDouble_' + name, [], function(err, res) {
proxy.invoke('replyDouble_' + name, "", [], function(err, res) {
assert(res == arg);
done(err);
});
Expand Down