File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -62,23 +62,25 @@ const { validateObject } = require('internal/validators');
62
62
function Server ( opts , requestListener ) {
63
63
if ( ! ( this instanceof Server ) ) return new Server ( opts , requestListener ) ;
64
64
65
+ let ALPNProtocols = [ 'http/1.1' ] ;
65
66
if ( typeof opts === 'function' ) {
66
67
requestListener = opts ;
67
68
opts = kEmptyObject ;
68
69
} else if ( opts == null ) {
69
70
opts = kEmptyObject ;
70
71
} else {
71
72
validateObject ( opts , 'options' ) ;
73
+ // Only one of ALPNProtocols and ALPNCallback can be set, so make sure we
74
+ // only set a default ALPNProtocols if the caller has not set either of them
75
+ if ( opts . ALPNProtocols || opts . ALPNCallback )
76
+ ALPNProtocols = undefined ;
72
77
}
73
78
74
79
FunctionPrototypeCall ( storeHTTPOptions , this , opts ) ;
75
80
FunctionPrototypeCall ( tls . Server , this ,
76
81
{
77
82
noDelay : true ,
78
- // http/1.0 is not defined as Protocol IDs in IANA
79
- // https://www.iana.org/assignments/tls-extensiontype-values
80
- // /tls-extensiontype-values.xhtml#alpn-protocol-ids
81
- ALPNProtocols : [ 'http/1.1' ] ,
83
+ ALPNProtocols,
82
84
...opts ,
83
85
} ,
84
86
_connectionListener ) ;
Original file line number Diff line number Diff line change @@ -45,3 +45,14 @@ const dftProtocol = {};
45
45
0 ) ;
46
46
assert . strictEqual ( server . listeners ( 'request' ) . length , 0 ) ;
47
47
}
48
+
49
+
50
+ // Validate that `createServer` only uses defaults when appropriate
51
+ {
52
+ const ALPNCallback = ( ) => { } ;
53
+ const server = https . createServer ( {
54
+ ALPNCallback,
55
+ } ) ;
56
+ assert . strictEqual ( server . ALPNProtocols , undefined ) ;
57
+ assert . strictEqual ( server . ALPNCallback , ALPNCallback ) ;
58
+ }
You can’t perform that action at this time.
0 commit comments