mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
https: only use default ALPNProtocols when appropriate
PR-URL: https://github.com/nodejs/node/pull/54411 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
826b7533e8
commit
71b36b3068
10
lib/https.js
10
lib/https.js
@ -62,6 +62,7 @@ const { validateObject } = require('internal/validators');
|
|||||||
function Server(opts, requestListener) {
|
function Server(opts, requestListener) {
|
||||||
if (!(this instanceof Server)) return new Server(opts, requestListener);
|
if (!(this instanceof Server)) return new Server(opts, requestListener);
|
||||||
|
|
||||||
|
let ALPNProtocols = ['http/1.1'];
|
||||||
if (typeof opts === 'function') {
|
if (typeof opts === 'function') {
|
||||||
requestListener = opts;
|
requestListener = opts;
|
||||||
opts = kEmptyObject;
|
opts = kEmptyObject;
|
||||||
@ -69,16 +70,17 @@ function Server(opts, requestListener) {
|
|||||||
opts = kEmptyObject;
|
opts = kEmptyObject;
|
||||||
} else {
|
} else {
|
||||||
validateObject(opts, 'options');
|
validateObject(opts, 'options');
|
||||||
|
// Only one of ALPNProtocols and ALPNCallback can be set, so make sure we
|
||||||
|
// only set a default ALPNProtocols if the caller has not set either of them
|
||||||
|
if (opts.ALPNProtocols || opts.ALPNCallback)
|
||||||
|
ALPNProtocols = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionPrototypeCall(storeHTTPOptions, this, opts);
|
FunctionPrototypeCall(storeHTTPOptions, this, opts);
|
||||||
FunctionPrototypeCall(tls.Server, this,
|
FunctionPrototypeCall(tls.Server, this,
|
||||||
{
|
{
|
||||||
noDelay: true,
|
noDelay: true,
|
||||||
// http/1.0 is not defined as Protocol IDs in IANA
|
ALPNProtocols,
|
||||||
// https://www.iana.org/assignments/tls-extensiontype-values
|
|
||||||
// /tls-extensiontype-values.xhtml#alpn-protocol-ids
|
|
||||||
ALPNProtocols: ['http/1.1'],
|
|
||||||
...opts,
|
...opts,
|
||||||
},
|
},
|
||||||
_connectionListener);
|
_connectionListener);
|
||||||
|
@ -45,3 +45,14 @@ const dftProtocol = {};
|
|||||||
0);
|
0);
|
||||||
assert.strictEqual(server.listeners('request').length, 0);
|
assert.strictEqual(server.listeners('request').length, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Validate that `createServer` only uses defaults when appropriate
|
||||||
|
{
|
||||||
|
const ALPNCallback = () => {};
|
||||||
|
const server = https.createServer({
|
||||||
|
ALPNCallback,
|
||||||
|
});
|
||||||
|
assert.strictEqual(server.ALPNProtocols, undefined);
|
||||||
|
assert.strictEqual(server.ALPNCallback, ALPNCallback);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user