mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
http: throw error if options of http.Server is array
If options of http.Server is array, throw ERR_INVALID_ARG_TYPE. Refs: https://github.com/nodejs/node/pull/24176 PR-URL: https://github.com/nodejs/node/pull/46283 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
26
lib/https.js
26
lib/https.js
@@ -53,25 +53,31 @@ let debug = require('internal/util/debuglog').debuglog('https', (fn) => {
|
||||
debug = fn;
|
||||
});
|
||||
const { URL, urlToHttpOptions, searchParamsSymbol } = require('internal/url');
|
||||
const { validateObject } = require('internal/validators');
|
||||
|
||||
function Server(opts, requestListener) {
|
||||
if (!(this instanceof Server)) return new Server(opts, requestListener);
|
||||
|
||||
if (typeof opts === 'function') {
|
||||
requestListener = opts;
|
||||
opts = undefined;
|
||||
}
|
||||
opts = { ...opts };
|
||||
|
||||
if (!opts.ALPNProtocols) {
|
||||
// http/1.0 is not defined as Protocol IDs in IANA
|
||||
// https://www.iana.org/assignments/tls-extensiontype-values
|
||||
// /tls-extensiontype-values.xhtml#alpn-protocol-ids
|
||||
opts.ALPNProtocols = ['http/1.1'];
|
||||
opts = kEmptyObject;
|
||||
} else if (opts == null) {
|
||||
opts = kEmptyObject;
|
||||
} else {
|
||||
validateObject(opts, 'options');
|
||||
}
|
||||
|
||||
FunctionPrototypeCall(storeHTTPOptions, this, opts);
|
||||
FunctionPrototypeCall(tls.Server, this, opts, _connectionListener);
|
||||
FunctionPrototypeCall(tls.Server, this,
|
||||
{
|
||||
noDelay: true,
|
||||
// http/1.0 is not defined as Protocol IDs in IANA
|
||||
// https://www.iana.org/assignments/tls-extensiontype-values
|
||||
// /tls-extensiontype-values.xhtml#alpn-protocol-ids
|
||||
ALPNProtocols: ['http/1.1'],
|
||||
...opts,
|
||||
},
|
||||
_connectionListener);
|
||||
|
||||
this.httpAllowHalfOpen = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user