https: make opts optional & immutable when create · nodejs/node@74741fa · GitHub
Skip to content

Commit 74741fa

Browse files
XadillaXaddaleax
authored andcommitted
https: make opts optional & immutable when create
`opts` in `createServer` will be immutable that won't change origional opts value. What's more, it's optional which can make `requestListener` be the first argument. PR-URL: #13599 Fixes: #13584 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
1 parent 3bb4ec8 commit 74741fa

3 files changed

Lines changed: 51 additions & 1 deletion

File tree

doc/api/https.md

Lines changed: 1 addition & 1 deletion

lib/https.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ const { urlToOptions, searchParamsSymbol } = require('internal/url');
3434
function Server(opts, requestListener) {
3535
if (!(this instanceof Server)) return new Server(opts, requestListener);
3636

37+
if (typeof opts === 'function') {
38+
requestListener = opts;
39+
opts = undefined;
40+
}
41+
opts = util._extend({}, opts);
42+
3743
if (process.features.tls_npn && !opts.NPNProtocols) {
3844
opts.NPNProtocols = ['http/1.1', 'http/1.0'];
3945
}
Lines changed: 44 additions & 0 deletions

0 commit comments

Comments
 (0)