-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 requests if SOAP service is not on port 80, do not crash on errors #228
Conversation
@jsdevel I probably should, the problem is that the error only happens when the server gets its own hostname from the HTTP host headers, which is the way most SOAP servers work, but not how node-soap server works. So to write a test for that using the current node-soap as a server I should first add that functionality to the server... The crash is probably much easier to reproduce, should look into that. I request this pull request is not closed until these issues are resolved... unless it's ok to merge. |
makes sense |
Added a test for the crash, it required to take the server object out of the single test scope but I hope that is ok. It is bad practice btw to start the server in the first test, because the order of tests is not guaranteed. You should use before, after, before each and after each hooks for preparing and closing the server. |
I think with mocha I've observed that tests are executed as listed. Still, better to avoid it. |
@jsdevel That's because in Node.js uses v8 in which object keys are in the same order as they are added to the object. However this is not guaranteed in JavaScript specification itself, and I would therefore like to avoid it. Quite unlikely that v8 would change in this respect though, because it would break a lot of crappy code. |
Nice. I wasn't aware of Object.keys! |
Modified the comparison from |
Should it return with ":80" then by default? |
Not necessarily
|
Can you write more of a unit test around lib/http.js if it's difficult to test using the server? |
Actually it already defaults to :80 actually... see I could create a fake server and check that the host header is correct, that would probably be the most sane test. Is that really necessary and should I separate this to two pull requests if I don't have time for that today? |
@aheckmann could come back and see this pull request now... |
'should return a valid error if the server stops responding': function(done) { | ||
soap.createClient('http://localhost:15099/stockquote?wsdl', function(err, client) { | ||
assert.ok(!err); | ||
server.close(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this use of server is confusing me. may be better to wrap the server startup/shutdown with in before()
and after()
so its more clear we clean up appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth to note however, that using before and after doesn't change the fact that you need an external variable referencing to the server instance, in order to be able to close it.
On 23.1.2014, at 17.06, Aaron Heckmann [email protected] wrote:
In test/server-test.js:
@@ -113,6 +115,18 @@ module.exports = {
done();
});
});
},
'should return a valid error if the server stops responding': function(done) {
soap.createClient('http://localhost:15099/stockquote?wsdl', function(err, client) {
assert.ok(!err);
this use of server is confusing me. may be better to wrap the server startup/shutdown with in before() and after() so its more clear we clean up appropriately.server.close(function() {
�
Reply to this email directly or view it on GitHub.
Also needs a rebase. |
Rebase is done, the server startup/shutdown should be fixed separately IMHO, but I can try to find time to fix that as well. |
@aheckmann Tests are now using beforeEach and afterEach, they still require a reference to the server variable, but nice thing is that the server is started separately for each test. So if a test closes the server it will be restarted for the next test. |
Crashes on me when I revert the lib/client.js, are you sure? I'm getting tired of this pull request...
|
Fix requests if SOAP service is not on port 80, do not crash on errors
ah my mistake. merged. |
Fix requests if SOAP service is not on port 80, do not crash on errors
Tests added for the crash.