Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a problem about Multi-Byte character #1042

Merged
merged 4 commits into from Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/server.js
Expand Up @@ -217,7 +217,7 @@ Server.prototype._requestListener = function (req, res) {
chunks.push(chunk);
});
source.on('end', function () {
var xml = chunks.join('');
var xml = Buffer.concat(chunks).toString();
var result;
var error;
self._processRequestXml(req, res, xml);
Expand Down
59 changes: 59 additions & 0 deletions test/post-data-concat-test.js
@@ -0,0 +1,59 @@
'use strict';

var fs = require('fs');
var soap = require('..');
var assert = require('assert');
var http = require('http');


describe('post data concat test', function () {
var server = http.createServer(function (req, res) { });

before(function () {
server.listen(51515);
});

after(function () {
server.close();
});

it('should consider the situation about multi-byte character between two tcp packets', function (done) {
var check = function (a, b) {
if (a && b) {
assert(a === b);
done();
}
};

var wsdl = 'test/wsdl/default_namespace.wsdl';
var xml = fs.readFileSync(wsdl, 'utf8');
var service = {
MyService: {
MyServicePort: {
MyOperation: function (arg) {
check(arg, postdata);
return "0";
}
}
}
};

soap.listen(server, '/wsdl', service, xml);

var postdata = "";
for (var i = 0; i < 20000; i++) {
postdata += "测试";
}

soap.createClient(wsdl, {
endpoint: 'http://localhost:51515/wsdl'
}, function (error, client) {
assert(!error);
client.MyOperation(postdata, function (error, response) {
assert(!error);
});
});

});
});