mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
6f0ec79e42
Make virtual methods throw an ERR_METHOD_NOT_IMPLEMENTED error instead of emitting it. The error is not recoverable and the only way to handle it is to override the method. PR-URL: https://github.com/nodejs/node/pull/31912 Refs: https://github.com/nodejs/node/pull/31818#pullrequestreview-359403469 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// Test the `allowHalfOpen` option of the `tls.TLSSocket` constructor.
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
const stream = require('stream');
|
|
const tls = require('tls');
|
|
|
|
{
|
|
// The option is ignored when the `socket` argument is a `net.Socket`.
|
|
const socket = new tls.TLSSocket(new net.Socket(), { allowHalfOpen: true });
|
|
assert.strictEqual(socket.allowHalfOpen, false);
|
|
}
|
|
|
|
{
|
|
// The option is ignored when the `socket` argument is a generic
|
|
// `stream.Duplex`.
|
|
const duplex = new stream.Duplex({
|
|
allowHalfOpen: false,
|
|
read() {}
|
|
});
|
|
const socket = new tls.TLSSocket(duplex, { allowHalfOpen: true });
|
|
assert.strictEqual(socket.allowHalfOpen, false);
|
|
}
|
|
|
|
{
|
|
const socket = new tls.TLSSocket();
|
|
assert.strictEqual(socket.allowHalfOpen, false);
|
|
}
|
|
|
|
{
|
|
// The option is honored when the `socket` argument is not specified.
|
|
const socket = new tls.TLSSocket(undefined, { allowHalfOpen: true });
|
|
assert.strictEqual(socket.allowHalfOpen, true);
|
|
}
|