diff options
author | koichik <koichik@improvement.jp> | 2012-01-17 12:34:53 +0400 |
---|---|---|
committer | koichik <koichik@improvement.jp> | 2012-01-17 20:09:27 +0400 |
commit | 534df2f8d207877f9d09d172d4ba92406e351aa0 (patch) | |
tree | 514fef18b8136270018ca9bd1f3054f61e24ff60 /test | |
parent | 549443a7cc600e93cc1d1d1630108e7d0a035500 (diff) |
tls: fix double 'error' events on HTTPS Requests
Fixes #2549.
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-tls-client-abort2.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/simple/test-tls-client-abort2.js b/test/simple/test-tls-client-abort2.js new file mode 100644 index 00000000000..f8119627687 --- /dev/null +++ b/test/simple/test-tls-client-abort2.js @@ -0,0 +1,45 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +if (!process.versions.openssl) { + console.error('Skipping because node compiled without OpenSSL.'); + process.exit(0); +} + +var common = require('../common'); +var assert = require('assert'); +var tls = require('tls'); + +var errors = 0; + +var conn = tls.connect(common.PORT, function() { + assert(false); // callback should never be executed +}); +conn.on('error', function() { + ++errors; + assert.doesNotThrow(function() { + conn.destroy(); + }); +}); + +process.on('exit', function() { + assert.equal(errors, 1); +}); |